Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ The API supports OpenTelemetry for distributed tracing and metrics. Traces and m
| Variable | Default | Description |
|---|---|---|
| `OPENTELEMETRY_ENABLED` | `false` | Master switch. Must be `true` for any telemetry to be emitted. |
| `OTEL_SERVICE_NAME` | `iri-facility-api` | The `service.name` resource attribute reported to the OTLP collector. |
| `OTEL_TRACES_ENABLED` | `true` | Enable trace export. Only takes effect when `OPENTELEMETRY_ENABLED=true`. |
| `OTEL_METRICS_ENABLED` | `true` | Enable metric export. Only takes effect when `OPENTELEMETRY_ENABLED=true`. |
| `OTLP_ENDPOINT` | `""` | gRPC endpoint for the OTLP collector (e.g. `http://otel-collector:4317`). When empty, telemetry is printed to the console. |
Expand Down
2 changes: 2 additions & 0 deletions app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

OPENTELEMETRY_ENABLED = os.environ.get("OPENTELEMETRY_ENABLED", "false").lower() == "true"
OPENTELEMETRY_DEBUG = os.environ.get("OPENTELEMETRY_DEBUG", "false").lower() == "true"
OTEL_SERVICE_NAME = os.environ.get("OTEL_SERVICE_NAME", "iri-facility-api")
OTLP_ENDPOINT = os.environ.get("OTLP_ENDPOINT", "")
OTEL_SAMPLE_RATE = float(os.environ.get("OTEL_SAMPLE_RATE", "0.2"))
OTEL_TRACES_ENABLED = os.environ.get("OTEL_TRACES_ENABLED", "true").lower() == "true"
Expand All @@ -69,6 +70,7 @@
logger.info(f"OPENTELEMETRY_ENABLED={OPENTELEMETRY_ENABLED}")
logger.info(f"OPENTELEMETRY_DEBUG={OPENTELEMETRY_DEBUG}")
logger.info(f"OTLP_ENDPOINT={OTLP_ENDPOINT}")
logger.info(f"OTEL_SERVICE_NAME={OTEL_SERVICE_NAME}")
logger.info(f"OTEL_SAMPLE_RATE={OTEL_SAMPLE_RATE}")
logger.info(f"OTEL_TRACES_ENABLED={OTEL_TRACES_ENABLED}")
logger.info(f"OTEL_METRICS_ENABLED={OTEL_METRICS_ENABLED}")
Expand Down
2 changes: 1 addition & 1 deletion app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
# OpenTelemetry Configuration
# ------------------------------------------------------------------
if config.OPENTELEMETRY_ENABLED:
resource = Resource.create({"service.name": "iri-facility-api", "service.version": config.API_VERSION, "service.endpoint": config.API_URL_ROOT})
resource = Resource.create({"service.name": config.OTEL_SERVICE_NAME, "service.version": config.API_VERSION, "service.endpoint": config.API_URL_ROOT})

if config.OTEL_TRACES_ENABLED:
samplerate = "1.0" if config.OPENTELEMETRY_DEBUG else config.OTEL_SAMPLE_RATE
Expand Down