owiwi
Opinionated tracing subscriber with OpenTelemetry export.
Known Limitations
- gRPC only.
OTEL_EXPORTER_OTLP_PROTOCOLignored OTEL_TRACES_EXPORTER/OTEL_METRICS_EXPORTERnot supported
Install
[]
= { = "2", = ["console"] }
= "0.1"
Usage
use Owiwi;
Hold the returned OwiwiGuard until shutdown. Dropping it stops export.
OTLP export
use ;
Custom backends
Use try_init_with with any type that implements SpanExporterConfig:
use ;
CLI Integration
Flatten Owiwi into your CLI struct. Requires the clap feature.
[]
= { = "4", = ["derive"] }
= { = "2.0.0", = ["clap"] }
= "0.1"
use Parser;
use Owiwi;
Backends
| Backend | Config type | Init method | Feature |
|---|---|---|---|
| Any OTLP collector | OtlpConfig |
try_init |
(default) |
| Console (stdout) | — | try_init_console |
console |
| Honeycomb | HoneycombConfig |
try_init_with |
honeycomb |
| Custom | impl SpanExporterConfig |
try_init_with |
— |
Environment Variables
Per the OpenTelemetry spec. With clap, each has a CLI flag.
| Variable | Flag | |
|---|---|---|
OTEL_SERVICE_NAME |
--service-name |
Service name |
OTEL_SDK_DISABLED |
--no-telemetry |
Disable telemetry |
OTEL_RESOURCE_ATTRIBUTES |
--resource-attrs |
key=value,key=value |
OTEL_EXPORTER_OTLP_ENDPOINT |
--otlp-endpoint |
Exporter endpoint |
OTEL_EXPORTER_OTLP_HEADERS |
--otlp-headers |
Extra gRPC headers |
OTEL_EXPORTER_OTLP_TIMEOUT |
--otlp-timeout |
Export timeout |
OTEL_TRACES_SAMPLER |
— | Sampler type (always_on, always_off, traceidratio) |
OTEL_TRACES_SAMPLER_ARG |
— | Sampler argument (e.g. ratio for traceidratio) |
RUST_LOG |
--trace-directive |
info / my_crate=debug |
OWIWI_EXPORT_LOG |
--export-directive |
Export filter (default: info) |
OWIWI_METRICS_INTERVAL |
--metrics-interval |
Metrics export interval (e.g. 30s) |
Features
| Feature | Default | |
|---|---|---|
clap |
CLI flags via clap::Args |
yes |
serde |
Deserialize on config types |
yes |
console |
Stdout exporters | no |
honeycomb |
Honeycomb exporter | no |
metrics |
Metrics via SdkMeterProvider |
no |
prometheus |
Prometheus OTLP export (implies metrics) |
no |
MSRV
1.94.0
Acknowledgments
Inspired by Instrumenting Axum.