Skip to content

Commit bd6c2ef

Browse files
samuelvkwongclaude
andauthored
Integrate OpenTelemetry from adit-radis-shared (#191)
* Integrate OpenTelemetry from adit-radis-shared Use the shared telemetry module from adit-radis-shared to set up OpenTelemetry traces, metrics, and logs. Telemetry is initialized in manage.py and asgi.py before Django loads, and the OTel logging handler is added conditionally in settings. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Update uv.lock for adit-radis-shared openobserve branch Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Add OpenObserve and OTel collector Docker infrastructure Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * uv lock * uv lock missing bracket in merge conflict * Move observability stack to centralized openradx-observability project Remove OpenObserve and OTel collector services from RADIS's Docker Compose stack. Telemetry is now sent directly to the centralized collector via OTEL_EXPORTER_OTLP_ENDPOINT. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Move OTEL_EXPORTER_OTLP_ENDPOINT out of compose, keep in env file Remove the OTLP endpoint mapping from docker-compose.base.yml since the observability stack is now centralized in openradx-observability. Add docker-compose.observability.yml.example as an opt-in overlay referencing the env variable, and ignore the active copy in .gitignore. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Use otel-collector.local endpoint in example.env Point OTEL_EXPORTER_OTLP_ENDPOINT to the collector on the shared openradx-observability network instead of host.docker.internal. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Rename observability overlay to override Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Pin adit-radis-shared to 0.20.0 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent b48e154 commit bd6c2ef

File tree

8 files changed

+317
-5
lines changed

8 files changed

+317
-5
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ pyvenv.cfg
143143
# Certificate files
144144
*.pem
145145

146+
# Override overlay (opt-in, copied from .example)
147+
docker-compose.override.yml
148+
146149
# RADIS specific
147150
backups/
148151
models/
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
x-observability: &observability
2+
networks:
3+
- default
4+
- openradx-observability
5+
environment:
6+
OTEL_EXPORTER_OTLP_ENDPOINT: ${OTEL_EXPORTER_OTLP_ENDPOINT:-}
7+
OTEL_PYTHON_DJANGO_EXCLUDED_URLS: "health/,static/.*"
8+
9+
networks:
10+
openradx-observability:
11+
external: true
12+
13+
services:
14+
init:
15+
<<: *observability
16+
web:
17+
<<: *observability
18+
default_worker:
19+
<<: *observability
20+
llm_worker:
21+
<<: *observability

example.env

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ REPORT_LLM_PROVIDER_URL="http://host.docker.internal:11434/v1"
109109
# 'cli generate-example-reports'.
110110
REPORT_LLM_PROVIDER_API_KEY="ollama"
111111

112+
# OpenTelemetry Configuration
113+
# Set this to the OTLP HTTP endpoint of the centralized openradx-observability stack.
114+
# See https://github.com/openradx/openradx-observability for setup instructions.
115+
OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector.local:4318
116+
112117
# Docker swarm mode does not respect the Docker Proxy client configuration
113118
# (see https://docs.docker.com/network/proxy/#configure-the-docker-client),
114119
# but we can set those environment variables manually.

manage.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ def initialize_debugger():
2424
def main():
2525
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "radis.settings.development")
2626

27+
# Initialize OpenTelemetry before Django loads to ensure all requests are traced
28+
from adit_radis_shared.telemetry import setup_opentelemetry
29+
30+
setup_opentelemetry()
31+
2732
initialize_debugger()
2833

2934
try:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ version = "0.0.0"
77
readme = "README.md"
88
requires-python = ">=3.12,<4.0"
99
dependencies = [
10-
"adit-radis-shared @ git+https://github.com/openradx/adit-radis-shared.git@0.19.1",
10+
"adit-radis-shared @ git+https://github.com/openradx/adit-radis-shared.git@0.20.0",
1111
"adrf>=0.1.9",
1212
"aiofiles>=24.1.0",
1313
"asyncinotify>=4.2.0",

radis/asgi.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,15 @@
1212

1313
import os
1414

15-
from django.core.asgi import get_asgi_application
16-
1715
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "radis.settings.development")
16+
17+
# Initialize OpenTelemetry before Django loads to ensure all requests are traced
18+
from adit_radis_shared.telemetry import setup_opentelemetry # noqa: E402
19+
20+
setup_opentelemetry()
21+
22+
from django.core.asgi import get_asgi_application # noqa: E402
23+
1824
django_asgi_app = get_asgi_application()
1925

2026
from channels.routing import ProtocolTypeRouter # noqa: E402

radis/settings/base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
from pathlib import Path
1414

15+
from adit_radis_shared.telemetry import add_otel_logging_handler, is_telemetry_active
1516
from environs import env
1617

1718
# During development and calling `manage.py` from the host we have to load the .env file manually.
@@ -266,6 +267,9 @@
266267
"root": {"handlers": ["console"], "level": "ERROR"},
267268
}
268269

270+
if is_telemetry_active():
271+
add_otel_logging_handler(LOGGING)
272+
269273
# Internationalization
270274
# https://docs.djangoproject.com/en/3.0/topics/i18n/
271275

uv.lock

Lines changed: 270 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)