Skip to content

Commit

Permalink
feat: profiling support (#938)
Browse files Browse the repository at this point in the history
  • Loading branch information
radubontila authored Aug 9, 2023
1 parent d8be166 commit b58f8a3
Show file tree
Hide file tree
Showing 10 changed files with 754 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sentry/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: sentry
description: A Helm chart for Kubernetes
type: application
version: 20.2.1
version: 20.3.0
appVersion: 23.7.1
dependencies:
- name: memcached
Expand Down
20 changes: 20 additions & 0 deletions sentry/templates/_helper.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
{{- define "relay.healthCheck.requestPath" -}}/api/relay/healthcheck/live/{{- end -}}
{{- define "snuba.port" -}}1218{{- end -}}
{{- define "symbolicator.port" -}}3021{{- end -}}
{{- define "vroom.port" -}}8085{{- end -}}

{{- define "relay.image" -}}
{{- default "getsentry/relay" .Values.images.relay.repository -}}
Expand Down Expand Up @@ -45,6 +46,12 @@
{{- default "latest" .Values.hooks.dbCheck.image.tag -}}
{{- end -}}

{{- define "vroom.image" -}}
{{- default "getsentry/vroom" .Values.images.vroom.repository -}}
:
{{- default .Chart.AppVersion .Values.images.vroom.tag -}}
{{- end -}}

{{/*
Expand the name of the chart.
*/}}
Expand Down Expand Up @@ -445,12 +452,25 @@ Common Snuba environment variables
{{- end }}
{{- end -}}

{{- define "vroom.env" -}}
- name: SENTRY_KAFKA_BROKERS_PROFILING
value: {{ include "sentry.kafka.bootstrap_servers_string" . | quote }}
- name: SENTRY_KAFKA_BROKERS_OCCURRENCES
value: {{ include "sentry.kafka.bootstrap_servers_string" . | quote }}
- name: SENTRY_BUCKET_PROFILES
value: file://localhost//var/lib/sentry-profiles
- name: SENTRY_SNUBA_HOST
value: http://{{ template "sentry.fullname" . }}-snuba:{{ template "snuba.port" . }}
{{- end -}}

{{/*
Common Sentry environment variables
*/}}
{{- define "sentry.env" -}}
- name: SNUBA
value: http://{{ template "sentry.fullname" . }}-snuba:{{ template "snuba.port" . }}
- name: VROOM
value: http://{{ template "sentry.fullname" . }}-vroom:{{ template "vroom.port" . }}
{{- if .Values.sentry.existingSecret }}
- name: SENTRY_SECRET_KEY
valueFrom:
Expand Down
11 changes: 11 additions & 0 deletions sentry/templates/configmap-sentry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,17 @@ data:
"organizations:transaction-metrics-extraction",
"organizations:session-replay",
{{- if .Values.sentry.features.enableProfiling }}
"organizations:profiling",
"organizations:profiling-ui-frames",
"organizations:profiling-using-transactions",
"organizations:profiling-beta",
"organizations:profiling-stacktrace-links",
"organizations:profiling-global-suspect-functions",
"organizations:profiling-cpu-chart",
"organizations:profiling-memory-chart",
{{ end -}}
"projects:alert-filters",
"projects:custom-inbound-filters",
"projects:data-forwarding",
Expand Down
141 changes: 141 additions & 0 deletions sentry/templates/deployment-sentry-ingest-profiles.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
{{- if .Values.sentry.features.enableProfiling }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "sentry.fullname" . }}-ingest-profiles
labels:
app: {{ template "sentry.fullname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
app.kubernetes.io/managed-by: "Helm"
{{- if .Values.asHook }}
{{- /* Add the Helm annotations so that deployment after asHook from true to false works */}}
annotations:
meta.helm.sh/release-name: "{{ .Release.Name }}"
meta.helm.sh/release-namespace: "{{ .Release.Namespace }}"
"helm.sh/hook": "post-install,post-upgrade"
"helm.sh/hook-weight": "10"
{{- end }}
spec:
revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
selector:
matchLabels:
app: {{ template "sentry.fullname" . }}
release: "{{ .Release.Name }}"
role: ingest-profiles
{{- if not .Values.sentry.ingestProfiles.autoscaling.enabled }}
replicas: {{ .Values.sentry.ingestProfiles.replicas }}
{{- end }}
template:
metadata:
annotations:
checksum/configYml: {{ .Values.config.configYml | toYaml | toString | sha256sum }}
checksum/sentryConfPy: {{ .Values.config.sentryConfPy | sha256sum }}
checksum/config.yaml: {{ include (print $.Template.BasePath "/configmap-sentry.yaml") . | sha256sum }}
{{- if .Values.sentry.ingestProfiles.annotations }}
{{ toYaml .Values.sentry.ingestProfiles.annotations | indent 8 }}
{{- end }}
labels:
app: {{ template "sentry.fullname" . }}
release: "{{ .Release.Name }}"
role: ingest-profiles
{{- if .Values.sentry.ingestProfiles.podLabels }}
{{ toYaml .Values.sentry.ingestProfiles.podLabels | indent 8 }}
{{- end }}
spec:
affinity:
{{- if .Values.sentry.ingestProfiles.affinity }}
{{ toYaml .Values.sentry.ingestProfiles.affinity | indent 8 }}
{{- end }}
{{- if .Values.sentry.ingestProfiles.nodeSelector }}
nodeSelector:
{{ toYaml .Values.sentry.ingestProfiles.nodeSelector | indent 8 }}
{{- end }}
{{- if .Values.sentry.ingestProfiles.tolerations }}
tolerations:
{{ toYaml .Values.sentry.ingestProfiles.tolerations | indent 8 }}
{{- end }}
{{- if .Values.images.sentry.imagePullSecrets }}
imagePullSecrets:
{{ toYaml .Values.images.sentry.imagePullSecrets | indent 8 }}
{{- end }}
{{- if .Values.dnsPolicy }}
dnsPolicy: {{ .Values.dnsPolicy | quote }}
{{- end }}
{{- if .Values.dnsConfig }}
dnsConfig:
{{ toYaml .Values.dnsConfig | indent 8 }}
{{- end }}
{{- if .Values.sentry.ingestProfiles.securityContext }}
securityContext:
{{ toYaml .Values.sentry.ingestProfiles.securityContext | indent 8 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}-ingest-profiles
image: "{{ template "sentry.image" . }}"
imagePullPolicy: {{ default "IfNotPresent" .Values.images.sentry.pullPolicy }}
command: ["sentry"]
args:
- "run"
- "ingest-profiles"
env:
- name: C_FORCE_ROOT
value: "true"
{{ include "sentry.env" . | indent 8 }}
{{- if .Values.sentry.ingestProfiles.env }}
{{ toYaml .Values.sentry.ingestProfiles.env | indent 8 }}
{{- end }}
volumeMounts:
- mountPath: /etc/sentry
name: config
readOnly: true
- mountPath: {{ .Values.filestore.filesystem.path }}
name: sentry-data
{{- if and (eq .Values.filestore.backend "gcs") .Values.filestore.gcs.secretName }}
- name: sentry-google-cloud-key
mountPath: /var/run/secrets/google
{{ end }}
{{- if .Values.sentry.ingestProfiles.volumeMounts }}
{{ toYaml .Values.sentry.ingestProfiles.volumeMounts | indent 8 }}
{{- end }}
resources:
{{ toYaml .Values.sentry.ingestProfiles.resources | indent 12 }}
{{- if .Values.sentry.ingestProfiles.containerSecurityContext }}
securityContext:
{{ toYaml .Values.sentry.ingestProfiles.containerSecurityContext | indent 12 }}
{{- end }}
{{- if .Values.sentry.ingestProfiles.sidecars }}
{{ toYaml .Values.sentry.ingestProfiles.sidecars | indent 6 }}
{{- end }}
{{- if .Values.serviceAccount.enabled }}
serviceAccountName: {{ .Values.serviceAccount.name }}-ingest-replay-recordings
{{- end }}
volumes:
- name: config
configMap:
name: {{ template "sentry.fullname" . }}-sentry
- name: sentry-data
{{- if and (eq .Values.filestore.backend "filesystem") .Values.filestore.filesystem.persistence.enabled (.Values.filestore.filesystem.persistence.persistentWorkers) }}
{{- if .Values.filestore.filesystem.persistence.existingClaim }}
persistentVolumeClaim:
claimName: {{ .Values.filestore.filesystem.persistence.existingClaim }}
{{- else }}
persistentVolumeClaim:
claimName: {{ template "sentry.fullname" . }}-data
{{- end }}
{{- else }}
emptyDir: {}
{{ end }}
{{- if and (eq .Values.filestore.backend "gcs") .Values.filestore.gcs.secretName }}
- name: sentry-google-cloud-key
secret:
secretName: {{ .Values.filestore.gcs.secretName }}
{{ end }}
{{- if .Values.sentry.ingestProfiles.volumes }}
{{ toYaml .Values.sentry.ingestProfiles.volumes | indent 6 }}
{{- end }}
{{- if .Values.sentry.ingestProfiles.priorityClassName }}
priorityClassName: "{{ .Values.sentry.ingestProfiles.priorityClassName }}"
{{- end }}
{{- end }}
150 changes: 150 additions & 0 deletions sentry/templates/deployment-snuba-profiling-functions-consumer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
{{- if .Values.sentry.features.enableProfiling }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "sentry.fullname" . }}-snuba-profiling-functions-consumer
labels:
app: {{ template "sentry.fullname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
app.kubernetes.io/managed-by: "Helm"
{{- if .Values.asHook }}
{{- /* Add the Helm annotations so that deployment after asHook from true to false works */}}
annotations:
meta.helm.sh/release-name: "{{ .Release.Name }}"
meta.helm.sh/release-namespace: "{{ .Release.Namespace }}"
"helm.sh/hook": "post-install,post-upgrade"
"helm.sh/hook-weight": "12"
{{- end }}
spec:
revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
selector:
matchLabels:
app: {{ template "sentry.fullname" . }}
release: "{{ .Release.Name }}"
role: snuba-profiling-functions-consumer
replicas: {{ .Values.snuba.profilingFunctionsConsumer.replicas }}
template:
metadata:
annotations:
checksum/snubaSettingsPy: {{ .Values.config.snubaSettingsPy | sha256sum }}
checksum/config.yaml: {{ include (print $.Template.BasePath "/configmap-snuba.yaml") . | sha256sum }}
{{- if .Values.snuba.profilingFunctionsConsumer.annotations }}
{{ toYaml .Values.snuba.profilingFunctionsConsumer.annotations | indent 8 }}
{{- end }}
labels:
app: {{ template "sentry.fullname" . }}
release: "{{ .Release.Name }}"
role: snuba-profiling-functions-consumer
{{- if .Values.snuba.profilingFunctionsConsumer.podLabels }}
{{ toYaml .Values.snuba.profilingFunctionsConsumer.podLabels | indent 8 }}
{{- end }}
spec:
affinity:
{{- if .Values.snuba.profilingFunctionsConsumer.affinity }}
{{ toYaml .Values.snuba.profilingFunctionsConsumer.affinity | indent 8 }}
{{- end }}
{{- if .Values.snuba.profilingFunctionsConsumer.nodeSelector }}
nodeSelector:
{{ toYaml .Values.snuba.profilingFunctionsConsumer.nodeSelector | indent 8 }}
{{- end }}
{{- if .Values.snuba.profilingFunctionsConsumer.tolerations }}
tolerations:
{{ toYaml .Values.snuba.profilingFunctionsConsumer.tolerations | indent 8 }}
{{- end }}
{{- if .Values.images.snuba.imagePullSecrets }}
imagePullSecrets:
{{ toYaml .Values.images.snuba.imagePullSecrets | indent 8 }}
{{- end }}
{{- if .Values.dnsPolicy }}
dnsPolicy: {{ .Values.dnsPolicy | quote }}
{{- end }}
{{- if .Values.dnsConfig }}
dnsConfig:
{{ toYaml .Values.dnsConfig | indent 8 }}
{{- end }}
{{- if .Values.snuba.profilingFunctionsConsumer.securityContext }}
securityContext:
{{ toYaml .Values.snuba.profilingFunctionsConsumer.securityContext | indent 8 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}-snuba
image: "{{ template "snuba.image" . }}"
imagePullPolicy: {{ default "IfNotPresent" .Values.images.snuba.pullPolicy }}
command:
- "snuba"
- "consumer"
- "--storage"
- "functions_raw"
- "--consumer-group"
- "functions_raw_group"
- "--auto-offset-reset"
- "{{ .Values.snuba.profilingFunctionsConsumer.autoOffsetReset }}"
- "--max-batch-time-ms"
- "750"
{{- if .Values.snuba.profilingFunctionsConsumer.maxBatchSize }}
- "--max-batch-size"
- "{{ .Values.snuba.profilingFunctionsConsumer.maxBatchSize }}"
{{- end }}
{{- if .Values.snuba.profilingFunctionsConsumer.processes }}
- "--processes"
- "{{ .Values.snuba.profilingFunctionsConsumer.processes }}"
{{- end }}
{{- if .Values.snuba.profilingFunctionsConsumer.inputBlockSize }}
- "--input-block-size"
- "{{ .Values.snuba.profilingFunctionsConsumer.inputBlockSize }}"
{{- end }}
{{- if .Values.snuba.profilingFunctionsConsumer.outputBlockSize }}
- "--output-block-size"
- "{{ .Values.snuba.profilingFunctionsConsumer.outputBlockSize }}"
{{- end }}
{{- if .Values.snuba.profilingFunctionsConsumer.maxBatchTimeMs }}
- "--max-batch-time-ms"
- "{{ .Values.snuba.profilingFunctionsConsumer.maxBatchTimeMs }}"
{{- end }}
{{- if .Values.snuba.profilingFunctionsConsumer.queuedMaxMessagesKbytes }}
- "--queued-max-messages-kbytes"
- "{{ .Values.snuba.profilingFunctionsConsumer.queuedMaxMessagesKbytes }}"
{{- end }}
{{- if .Values.snuba.profilingFunctionsConsumer.queuedMinMessages }}
- "--queued-min-messages"
- "{{ .Values.snuba.profilingFunctionsConsumer.queuedMinMessages }}"
{{- end }}
{{- if .Values.snuba.profilingFunctionsConsumer.noStrictOffsetReset }}
- "--no-strict-offset-reset"
{{- end }}
ports:
- containerPort: {{ template "snuba.port" }}
env:
{{ include "sentry.snuba.env" . | indent 8 }}
{{- if .Values.snuba.profilingFunctionsConsumer.env }}
{{ toYaml .Values.snuba.profilingFunctionsConsumer.env | indent 8 }}
{{- end }}
envFrom:
- secretRef:
name: {{ template "sentry.fullname" . }}-snuba-env
volumeMounts:
- mountPath: /etc/snuba
name: config
readOnly: true
{{- if .Values.snuba.profilingFunctionsConsumer.volumeMounts }}
{{ toYaml .Values.snuba.profilingFunctionsConsumer.volumeMounts | indent 8 }}
{{- end }}
resources:
{{ toYaml .Values.snuba.profilingFunctionsConsumer.resources | indent 12 }}
{{- if .Values.snuba.profilingFunctionsConsumer.containerSecurityContext }}
securityContext:
{{ toYaml .Values.snuba.profilingFunctionsConsumer.containerSecurityContext | indent 12 }}
{{- end }}
{{- if .Values.serviceAccount.enabled }}
serviceAccountName: {{ .Values.serviceAccount.name }}-snuba
{{- end }}
volumes:
- name: config
configMap:
name: {{ template "sentry.fullname" . }}-snuba
{{- if .Values.snuba.profilingFunctionsConsumer.volumes }}
{{ toYaml .Values.snuba.profilingFunctionsConsumer.volumes | indent 8 }}
{{- end }}
{{- end }}
Loading

0 comments on commit b58f8a3

Please sign in to comment.