From a96271ff70a1c9db12bf6352f5ff6b1169402c8d Mon Sep 17 00:00:00 2001 From: Tom de Bruijn Date: Fri, 23 Aug 2024 11:34:34 +0200 Subject: [PATCH] Configure OpenTelemetry services for Django apps Make it easier to test if we set some expected metadata. --- python/django4-celery/app/manage.py | 1 + python/django4-celery/app/tasks.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/python/django4-celery/app/manage.py b/python/django4-celery/app/manage.py index 19e41ddc..cc22ad08 100755 --- a/python/django4-celery/app/manage.py +++ b/python/django4-celery/app/manage.py @@ -9,6 +9,7 @@ def main(): """Run administrative tasks.""" + os.environ["OTEL_SERVICE_NAME"] = "django-app" os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'appsignal_python_opentelemetry.settings') appsignal.start() diff --git a/python/django4-celery/app/tasks.py b/python/django4-celery/app/tasks.py index a1c2951c..c0d30eb7 100644 --- a/python/django4-celery/app/tasks.py +++ b/python/django4-celery/app/tasks.py @@ -1,4 +1,5 @@ import time +import os import appsignal @@ -11,6 +12,7 @@ @worker_process_init.connect(weak=False) def init_celery_tracing(*args, **kwargs): + os.environ["OTEL_SERVICE_NAME"] = "celery-app" appsignal.start()