From b3b8cd807d560574f653b42e040c786fce318b64 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Tue, 7 Jul 2020 17:53:35 +0200 Subject: [PATCH] root: expose APM settings in helm chart --- docs/installation/kubernetes.md | 5 +++++ helm/templates/configmap.yaml | 4 ++++ helm/values.yaml | 5 +++++ passbook/root/settings.py | 13 +++++++++++++ 4 files changed, 27 insertions(+) diff --git a/docs/installation/kubernetes.md b/docs/installation/kubernetes.md index 35882adab..7e47718b2 100644 --- a/docs/installation/kubernetes.md +++ b/docs/installation/kubernetes.md @@ -22,6 +22,11 @@ config: # Log level used by web and worker # Can be either debug, info, warning, error log_level: warning + # Optionally enable Elastic APM Support + apm: + enabled: false + server_url: "" + secret_token: "" # This Helm chart ships with built-in Prometheus ServiceMonitors and Rules. # This requires the CoreOS Prometheus Operator. diff --git a/helm/templates/configmap.yaml b/helm/templates/configmap.yaml index c4bd4d71d..313a6c8c5 100644 --- a/helm/templates/configmap.yaml +++ b/helm/templates/configmap.yaml @@ -21,3 +21,7 @@ data: message_queue_db: 1 error_reporting: {{ .Values.config.error_reporting }} log_level: "{{ .Values.config.log_level }}" + apm: + enabled: {{ .Values.config.apm.enabled }} + server_url: "{{ .Values.config.apm.server_url }}" + secret_token: "{{ .Values.config.apm.server_token }}" diff --git a/helm/values.yaml b/helm/values.yaml index 937a7fce8..4fb14448d 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -14,6 +14,11 @@ config: # Log level used by web and worker # Can be either debug, info, warning, error log_level: warning + # Optionally enable Elastic APM Support + apm: + enabled: false + server_url: "" + secret_token: "" # This Helm chart ships with built-in Prometheus ServiceMonitors and Rules. # This requires the CoreOS Prometheus Operator. diff --git a/passbook/root/settings.py b/passbook/root/settings.py index 4e7c2b381..149a6ee2c 100644 --- a/passbook/root/settings.py +++ b/passbook/root/settings.py @@ -281,6 +281,19 @@ if not DEBUG and _ERROR_REPORTING: release="passbook@%s" % __version__, ) +_APM_ENABLED = CONFIG.y("apm.enabled", True) +if _APM_ENABLED: + INSTALLED_APPS.append("elasticapm.contrib.django") + ELASTIC_APM = { + "CLOUD_PROVIDER": False, + "DEBUG": DEBUG, + "SERVICE_NAME": "passbook", + "SERVICE_VERSION": __version__, + "SECRET_TOKEN": CONFIG.y("apm.secret_token", ""), + "SERVER_URL": CONFIG.y("apm.secret_token", "http://localhost:8200"), + } + + # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/2.1/howto/static-files/