From fb087789023477591ea32042b968fec04508f5b9 Mon Sep 17 00:00:00 2001 From: James McKinney <26463+jpmckinney@users.noreply.github.com> Date: Mon, 13 Apr 2026 18:30:16 -0400 Subject: [PATCH] build: Make telemetry optional Start telemetry services with: docker compose --profile telemetry up --- DataSpace/asgi.py | 5 +++-- DataSpace/wsgi.py | 5 +++-- docker-compose.yml | 4 ++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/DataSpace/asgi.py b/DataSpace/asgi.py index d3cfa0c4..dc791a8e 100644 --- a/DataSpace/asgi.py +++ b/DataSpace/asgi.py @@ -14,8 +14,9 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "DataSpace.settings") # Initialize OpenTelemetry before application -from api.telemetry import setup_telemetry +if os.getenv("TELEMETRY_URL"): + from api.telemetry import setup_telemetry -setup_telemetry() # Initialize telemetry for ASGI application + setup_telemetry() # Initialize telemetry for ASGI application application = get_asgi_application() diff --git a/DataSpace/wsgi.py b/DataSpace/wsgi.py index 0fa66c64..4fd7d875 100644 --- a/DataSpace/wsgi.py +++ b/DataSpace/wsgi.py @@ -12,8 +12,9 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "DataSpace.settings") # Initialize OpenTelemetry before application -from api.telemetry import setup_telemetry +if os.getenv("TELEMETRY_URL"): + from api.telemetry import setup_telemetry -setup_telemetry() # Initialize telemetry for production application + setup_telemetry() # Initialize telemetry for production application application = get_wsgi_application() diff --git a/docker-compose.yml b/docker-compose.yml index 607d99b4..5566ea94 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -111,6 +111,7 @@ services: image: docker.elastic.co/elasticsearch/elasticsearch:7.16.2 container_name: telemetry_elasticsearch restart: always + profiles: ["telemetry"] ulimits: memlock: soft: -1 @@ -140,6 +141,7 @@ services: kibana: image: docker.elastic.co/kibana/kibana:7.16.2 container_name: kibana + profiles: ["telemetry"] environment: ELASTICSEARCH_URL: "http://telemetry_elasticsearch:9200" ELASTICSEARCH_HOSTS: '["http://telemetry_elasticsearch:9200"]' @@ -155,6 +157,7 @@ services: apm-server: image: docker.elastic.co/apm/apm-server:7.16.2 container_name: apm-server + profiles: ["telemetry"] user: apm-server restart: always command: @@ -199,6 +202,7 @@ services: otel-collector: image: otel/opentelemetry-collector:latest container_name: otel-collector + profiles: ["telemetry"] restart: always command: "--config=/etc/otel-collector-config.yaml" volumes: