Available on crate feature
tracing_subscriber_ext only.Expand description
Flexible tracing configuration with builder pattern.
Provides TracingConfig for configurable tracing setup with format options,
output destinations, level filtering, and OpenTelemetry integration.
§Example
use init_tracing_opentelemetry::TracingConfig;
// Use preset with global subscriber (default)
let _guard = TracingConfig::development().init_subscriber()?;
// Custom configuration with global subscriber
let _guard = TracingConfig::default()
.with_json_format()
.with_stderr()
.with_log_directives("debug")
.init_subscriber()?;
// Non-global subscriber (thread-local)
let guard = TracingConfig::development()
.with_global_subscriber(false)
.init_subscriber()?;
// Guard must be kept alive for subscriber to remain active
assert!(guard.is_non_global());
// Without OpenTelemetry (just logging)
let guard = TracingConfig::minimal()
.with_otel(false)
.init_subscriber()?;
// Works fine - guard.otel_guard is None
assert!(!guard.has_otel());
assert!(guard.otel_guard.is_none());
// Direct field access is also possible
if let Some(otel_guard) = &guard.otel_guard {
// Use otel_guard...
}Structs§
- Feature
Set - Configuration for optional tracing features
- Guard
- Combined guard that handles both
OtelGuardand optionalDefaultGuard - Level
Config - Configuration for log level filtering
- Otel
Config - Configuration for OpenTelemetry integration
- Tracing
Config - Main configuration builder for tracing setup Default create a new tracing configuration with sensible defaults
Enums§
- LogFormat
- Configuration for log output format
- LogTimer
- Writer
Config - Configuration for log output destination