autumn-plugin-otel
OpenTelemetry traces, metrics and logs for the Autumn web framework, exported over OTLP to a configurable collector endpoint.
Quickstart
Add the plugin, then opt in. The plugin reads [otel] in autumn.toml:
[]
= true
= "http://localhost:4317"
= "my-app"
= 0.1
= "grpc" # or "http"
use OtelPlugin;
# async
Or set it with environment variables: AUTUMN_OTEL__ENABLED=true,
AUTUMN_OTEL__ENDPOINT, AUTUMN_OTEL__SERVICE_NAME, AUTUMN_OTEL__SAMPLE_RATIO,
AUTUMN_OTEL__PROTOCOL.
Run the example:
What it does
- Installs a tier-1
TelemetryProviderthat owns the global tracing subscriber. This is the framework's sanctioned hook for exporter setup — the plugin does not fight the default initializer, it replaces it throughwith_telemetry_provider. - Exports three signals to the OTLP collector: traces (via a
tracing-opentelemetrylayer), metrics (via the global OTel meter provider) and logs (tracing events forwarded as OTLP log records). - Samples with a parent-based sampler over the configured
sample_ratio(0.0 to 1.0). - Tags every signal with
service.name,service.version,deployment.environmentandservice.namespacewhen set. - Reports exporter configuration on
/actuator/healthunderotel(health-only: a sick collector never blocks a deploy). The details name the transport, the sample ratio, the enabled signals and the service — never the collector endpoint. - Flushes all providers at shutdown.
Configuration
| Key | Env var | Default | Notes |
|---|---|---|---|
enabled |
AUTUMN_OTEL__ENABLED |
false |
The plugin installs nothing when off. |
endpoint |
AUTUMN_OTEL__ENDPOINT |
http://localhost:4317 |
Absolute URI with scheme and authority. |
service_name |
AUTUMN_OTEL__SERVICE_NAME |
autumn-app |
The service.name resource attribute. |
service_version |
AUTUMN_OTEL__SERVICE_VERSION |
unknown |
The service.version resource attribute. |
service_namespace |
AUTUMN_OTEL__SERVICE_NAMESPACE |
unset | The service.namespace resource attribute. |
environment |
AUTUMN_OTEL__ENVIRONMENT |
development |
The deployment.environment resource attribute. |
sample_ratio |
AUTUMN_OTEL__SAMPLE_RATIO |
1.0 |
0.0 to 1.0, parent-based. |
protocol |
AUTUMN_OTEL__PROTOCOL |
grpc |
grpc or http (protobuf). |
traces |
AUTUMN_OTEL__TRACES |
true |
Export spans. |
metrics |
AUTUMN_OTEL__METRICS |
true |
Export instruments. |
logs |
AUTUMN_OTEL__LOGS |
true |
Export tracing events as logs. |
health_check |
AUTUMN_OTEL__HEALTH_CHECK |
true |
The otel health indicator. |
Layering: defaults < [otel] in autumn.toml < [profile.<name>.otel] <
[otel] in autumn-<name>.toml < AUTUMN_OTEL__* variables.
Metrics in handlers
use ;
use AppState;
Cargo features
grpc(default): OTLP over gRPC via tonic.http(default): OTLP over HTTP protobuf via reqwest.tls: TLS trust roots forhttps://gRPC endpoints. HTTP uses rustls.
Every combination builds, including --no-default-features. A build without
grpc or http has no transport, so an enabled [otel] section fails
validation at boot and names the feature to enable.
Known issues
TelemetryInitErroris#[non_exhaustive], so the provider can not return a typed init error. An exporter that fails to build falls back to a logging-only subscriber with a warning on stderr (the framework's non-strict shape). A bad[otel]configuration still stops the boot, via the startup hook.- The plugin replaces Autumn's default telemetry initializer, so the framework's
log-capture buffer and the
/actuator/loggersreload handle are not installed. - OTLP has no cheap health probe. The
otelhealth indicator reports the exporter configuration only; it never contacts the collector, and it never exposes the collector endpoint. - gRPC export needs a Tokio runtime at provider build time (tonic requirement); Autumn always boots on Tokio, so this holds in practice.
- The tracing-to-OTLP log bridge forwards each event's message and target; it does not forward every structured field.