Skip to main content

Module otel

Module otel 

Source
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] macro
  • otel-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 spans

Structs§

Histogram
Histogram for latency measurements
MetricsRecorder
MetricsRecorder for testing - records all metrics
ObservabilityBuilder
Builder for configuring observability (tracing, metrics, logging)
ObservabilityGuard
Guard that keeps the observability stack active
OtelConfigDeprecated
OTel configuration (legacy)
Span
Span represents a unit of work in distributed tracing
SpanContext
SpanContext for distributed tracing
SpanRecorder
SpanRecorder for testing - records all spans

Enums§

ExporterTypeDeprecated
Exporter type (legacy)
ObservabilityError
Errors that can occur during observability setup

Functions§

configure_batch_exportDeprecated
Configure batch export (placeholder)
configure_exporterDeprecated
Configure exporter (placeholder)
configure_from_fileDeprecated
Configure from file (placeholder)
configure_samplingDeprecated
Configure sampling rate (placeholder)
current_span_idDeprecated
Get the current span ID (placeholder - use tracing for real spans)
current_trace_idDeprecated
Get the current trace ID (placeholder - use tracing for real traces)
disable_tracingDeprecated
Disable tracing (placeholder)
enable_tracingDeprecated
Enable tracing (placeholder)
extract_contextDeprecated
Extract context from headers (placeholder)
get_baggageDeprecated
Get baggage value (placeholder)
get_configDeprecated
Get current config (placeholder)
get_export_countDeprecated
Get export count (placeholder)
inject_contextDeprecated
Inject context into headers (placeholder)
set_baggageDeprecated
Set baggage value (placeholder)
start_traceDeprecated
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