Expand description
One-call OpenTelemetry bootstrap — traces + metrics + logs with OTLP export.
Call init_telemetry at main() before starting the server. Keep the returned
TelemetryHandles alive for the duration of the process — dropping them flushes
and shuts down both providers.
Configuration is via environment variables per the OpenTelemetry spec:
OTEL_EXPORTER_OTLP_ENDPOINT(default:http://localhost:4317for gRPC,http://localhost:4318for HTTP)OTEL_EXPORTER_OTLP_PROTOCOL(grpcorhttp/protobuf) — selects transport when both features are enabledOTEL_EXPORTER_OTLP_TIMEOUT— export timeout in milliseconds (default: 10 000 ms)OTEL_SERVICE_NAME(overridden by theservice_nameargument)OTEL_TRACES_SAMPLER/OTEL_TRACES_SAMPLER_ARG(fallback when no explicit sampler is set)
§Env var handling: otel-bootstrap vs SDK
| Env var | Handled by |
|---|---|
OTEL_SERVICE_NAME | otel-bootstrap (falls back to SDK default) |
OTEL_TRACES_SAMPLER / OTEL_TRACES_SAMPLER_ARG | otel-bootstrap |
OTEL_EXPORTER_OTLP_PROTOCOL | otel-bootstrap |
OTEL_EXPORTER_OTLP_ENDPOINT | otel-bootstrap |
OTEL_EXPORTER_OTLP_TIMEOUT | otel-bootstrap |
OTEL_BSP_MAX_EXPORT_BATCH_SIZE | SDK (batch span processor) |
OTEL_METRIC_EXPORT_INTERVAL | SDK (periodic reader) |
Per-signal endpoints (OTEL_EXPORTER_OTLP_TRACES_ENDPOINT etc.) | SDK |
Structs§
- Telemetry
- Entry point for configuring telemetry via a builder pattern.
- Telemetry
Builder - Builder for configuring telemetry options incrementally.
- Telemetry
Handles - Handles returned by
init_telemetryorTelemetryBuilder::init.
Enums§
- Export
Protocol - OTLP export protocol.
- Trace
Sampler - Trace sampler configuration.
Functions§
- build_
resource - Build a
Resourceenriched with semantic-convention attributes. - init_
telemetry - Initialise OpenTelemetry traces + metrics with OTLP gRPC export.
- init_
telemetry_ with_ sampler - Initialise OpenTelemetry traces + metrics with OTLP gRPC export and an explicit trace sampler.