src.asqi.telemetry

Shared OpenTelemetry SDK bootstrap for asqi-engineer runtimes (AIP-2890).

Both the CLI entrypoint (asqi.main) and the FastAPI service (services/asqi-runner/app.py) instrument code that calls opentelemetry.metrics.get_meter() / opentelemetry.trace.get_tracer() (see asqi.workflow). The bare opentelemetry-api package is a no-op until a real SDK MeterProvider/TracerProvider has been installed via metrics.set_meter_provider() / trace.set_tracer_provider() — this module is the one place that does that, so both runtimes share a single, proven-correct implementation instead of two copies that can drift.

Enabled by setting OTEL_EXPORTER_OTLP_ENDPOINT; a no-op otherwise.

Resource attributes (service.name, deployment.environment.name, etc.) are picked up automatically by the SDK from OTEL_SERVICE_NAME / OTEL_RESOURCE_ATTRIBUTES per the OpenTelemetry spec when a MeterProvider/TracerProvider is constructed with no explicit resource= argument — this module intentionally does not duplicate that parsing.

The OTLP HTTP exporters likewise read OTEL_EXPORTER_OTLP_ENDPOINT and append the standard /v1/traces and /v1/metrics signal paths themselves; this module does not construct those URLs manually.

Functions

is_enabled(→ bool)

Whether OTLP export is configured for this process.

bootstrap(→ None)

Install real SDK MeterProvider/TracerProvider, once per process.

shutdown(→ None)

Flush and shut down the providers installed by bootstrap().

Module Contents

src.asqi.telemetry.is_enabled() bool

Whether OTLP export is configured for this process.

src.asqi.telemetry.bootstrap() None

Install real SDK MeterProvider/TracerProvider, once per process.

No-op when OTEL_EXPORTER_OTLP_ENDPOINT is unset. Idempotent: safe to call from multiple call sites (e.g. a runtime’s own startup path plus this shared module) without installing a second provider or emitting duplicate exporters.

src.asqi.telemetry.shutdown() None

Flush and shut down the providers installed by bootstrap().

Safe to call even if bootstrap() was never called or was a no-op.