pub fn init_tracing_with_fallbacks(
log_level: Level,
fallback_service_name: &'static str,
fallback_service_version: &'static str,
) -> TracerProvider
Expand description
Initializes tracing with OpenTelemetry integration and fallback service information.
This function sets up a complete tracing infrastructure including:
- A temporary subscriber for setup logging
- Resource detection from environment variables with fallbacks
- OTLP tracer provider initialization
- Global propagator configuration
- Final subscriber with both console output and OpenTelemetry export
§Arguments
log_level
: The minimum log level for eventsfallback_service_name
: Default service name if not found in environment variablesfallback_service_version
: Default service version if not found in environment variables
§Returns
A configured TracerProvider
that should be kept alive for the duration of the application
and passed to shutdown_tracer_provider
on shutdown.
§Examples
use telemetry_rust::{init_tracing_with_fallbacks, shutdown_tracer_provider};
use tracing::Level;
let tracer_provider = init_tracing_with_fallbacks(Level::INFO, "my-service", "1.0.0");
// Your application code here...
shutdown_tracer_provider(&tracer_provider);
§Panics
This function will panic if:
- The OTLP tracer provider cannot be initialized
- The text map propagator cannot be configured