Available on crate feature
otel only.Expand description
OpenTelemetry automatic instrumentation for distributed tracing.
Use the #[traced] macro to automatically instrument your functions:
ⓘ
use allframe::otel::traced;
#[traced]
async fn fetch_user(id: &str) -> User {
// Automatically creates a span with function name
}OpenTelemetry automatic instrumentation
This module provides automatic distributed tracing, metrics, and context propagation for AllFrame applications.
§Features
otel- Basic tracing support with the#[traced]macrootel-otlp- Full OpenTelemetry integration with OTLP export
§Quick Start
ⓘ
use allframe_core::otel::Observability;
let _guard = Observability::builder("my-service")
.service_version(env!("CARGO_PKG_VERSION"))
.environment_from_env()
.otlp_endpoint_from_env()
.json_logging()
.log_level_from_env()
.build()?;
// Guard keeps the subscriber active
// When dropped, flushes pending spansStructs§
- Histogram
- Histogram for latency measurements
- Metrics
Recorder - MetricsRecorder for testing - records all metrics
- Observability
Builder - Builder for configuring observability (tracing, metrics, logging)
- Observability
Guard - Guard that keeps the observability stack active
- Otel
Config Deprecated - OTel configuration (legacy)
- Span
- Span represents a unit of work in distributed tracing
- Span
Context - SpanContext for distributed tracing
- Span
Recorder - SpanRecorder for testing - records all spans
Enums§
- Exporter
Type Deprecated - Exporter type (legacy)
- Observability
Error - Errors that can occur during observability setup
Functions§
- configure_
batch_ export Deprecated - Configure batch export (placeholder)
- configure_
exporter Deprecated - Configure exporter (placeholder)
- configure_
from_ file Deprecated - Configure from file (placeholder)
- configure_
sampling Deprecated - Configure sampling rate (placeholder)
- current_
span_ id Deprecated - Get the current span ID (placeholder - use tracing for real spans)
- current_
trace_ id Deprecated - Get the current trace ID (placeholder - use tracing for real traces)
- disable_
tracing Deprecated - Disable tracing (placeholder)
- enable_
tracing Deprecated - Enable tracing (placeholder)
- extract_
context Deprecated - Extract context from headers (placeholder)
- get_
baggage Deprecated - Get baggage value (placeholder)
- get_
config Deprecated - Get current config (placeholder)
- get_
export_ count Deprecated - Get export count (placeholder)
- inject_
context Deprecated - Inject context into headers (placeholder)
- set_
baggage Deprecated - Set baggage value (placeholder)
- start_
trace Deprecated - Start a new trace (placeholder)
Type Aliases§
- Observability
- Type alias for the builder
Attribute Macros§
- traced
- Marks a function to be automatically traced with OpenTelemetry