Skip to main content

Crate autumn_plugin_otel

Crate autumn_plugin_otel 

Source
Expand description

Autumn plugin for OpenTelemetry.

Add OtelPlugin to the app. Spans, instruments and tracing events export to the configured OTLP collector over gRPC or HTTP.

use autumn_plugin_otel::OtelPlugin;

autumn_web::app()
    .plugin(OtelPlugin::new().configure(|c| {
        c.enabled = true;
        c.service_name = "my-app".into();
        c.sample_ratio = 0.1;
    }))
    .run()
    .await;

The plugin reads [otel] in autumn.toml. See config for the keys.

§What the plugin gives

  • A tier-1 TelemetryProvider that owns the global tracing subscriber and wires OTLP exporters for three signals.
  • Traces: a tracing-opentelemetry layer with a parent-based sampler.
  • Metrics: an SDK meter provider installed as the global provider, plus metrics helpers.
  • Logs: a bridge layer that forwards tracing events as OTLP log records.
  • OtelTelemetry: the handle in the app state, with a handler extractor.
  • A health indicator that reports the exporter configuration (never the collector endpoint).
  • A shutdown hook that flushes every provider.

§Limits

  • The plugin replaces Autumn’s default telemetry initializer. The framework’s log-capture buffer and the /actuator/loggers reload handle belong to the default provider and are not installed.
  • TelemetryInitError is #[non_exhaustive], so the provider can not build one. An exporter that fails to build falls back to a logging-only subscriber with a warning on stderr. A bad [otel] configuration stops the boot in the startup hook.
  • OTLP has no cheap health probe. The health check reports the exporter configuration. It never contacts the collector and never exposes the collector endpoint.
  • https gRPC endpoints need the tls crate feature. HTTP uses rustls through reqwest.
  • The tracing-to-OTLP log bridge forwards each event’s message and target; it does not forward every structured field.

§Shutdown

Autumn marks the shutdown before it drains the requests. The shutdown hook flushes the trace, metric and log providers. The exporters stay alive for the drain.

Re-exports§

pub use config::ConfigError;
pub use config::DEFAULT_SECTION;
pub use config::OtelConfig;
pub use config::OtelProtocol;
pub use metrics::OtelMetrics;
pub use metrics::meter;
pub use metrics::meter_named;

Modules§

config
The [otel] section of autumn.toml.
metrics
Meter helpers for application instruments.

Structs§

OtelPlugin
Installs an OpenTelemetry pipeline in an Autumn app.
OtelTelemetry
The running OpenTelemetry pipeline.

Enums§

ErrorKind
The kind of an OtelError.
OtelError
An error from the plugin.

Constants§

PLUGIN_NAME
The plugin name in Autumn diagnostics.

Traits§

OtelResultExt
Extends Result<T, OtelError> with an HTTP conversion.