Expand description
A comprehensive OpenTelemetry telemetry library for Rust applications.
This crate provides easy-to-use telemetry integration for Rust applications, with support for OpenTelemetry tracing, metrics, and logging. It includes middleware for popular frameworks like Axum and AWS Lambda, along with utilities for context propagation and configuration.
§Features
- OpenTelemetry tracing instrumentation
- Formatted logs with tracing metadata
- Context Propagation for incoming and outgoing HTTP requests
- Axum middleware to instrument http services
- AWS Lambda instrumentation layer
- AWS SDK instrumentation with automatic attribute extraction
- Integration testing tools
§Available Feature Flags
§Core Features
axum
: Axum web framework middleware supporttest
: Testing utilities for OpenTelemetry validationzipkin
: Zipkin context propagation support (enabled by default)future
: Future instrumentation utilities (mostly used internally)
§AWS Features
aws-span
: AWS SDK span creation utilitiesaws-instrumentation
: Lightweight manual instrumentation for AWS SDK operationsaws-stream-instrumentation
: Instrumentation for AWS SDK pagination streamsaws-fluent-builder-instrumentation
: Core traits for fluent builders instrumentation (see service-specific features)aws-lambda
: AWS Lambda runtime middleware
§AWS Service-Specific Features
aws-dynamodb
: DynamoDB automatic fluent builders instrumentationaws-firehose
: Firehose automatic fluent builders instrumentationaws-sns
: SNS automatic fluent builders instrumentationaws-sqs
: SQS automatic fluent builders instrumentation
§Feature Bundles
aws
: All core AWS features (span + instrumentation + stream instrumentation)aws-full
: All AWS features including Lambda and all service-specific instrumentationsfull
: All features enabled
§Quick Start
use telemetry_rust::{init_tracing, shutdown_tracer_provider};
use tracing::Level;
// Initialize telemetry
let tracer_provider = init_tracing!(Level::INFO);
// Your application code here...
// Shutdown telemetry when done
shutdown_tracer_provider(&tracer_provider);
Re-exports§
Modules§
- fmt
- JSON formatting utilities for structured logging with OpenTelemetry.
- future
- Future instrumentation utilities for async operation monitoring.
- global
- Utilities for working with global telemetry primitives
- http
- HTTP utilities for OpenTelemetry context propagation through headers.
- middleware
- Middleware integrations for popular web frameworks and platforms.
- otlp
- OpenTelemetry Protocol (OTLP) configuration and initialization utilities.
- propagation
- Context propagation utilities for distributed tracing across service boundaries.
- semconv
- Semantic Attributes
- test
- Testing utilities for OpenTelemetry integration testing and validation.
Macros§
- init_
tracing - Convenience macro for initializing tracing with package name and version as fallbacks.
Structs§
- Context
- An execution-scoped collection of values.
- Detect
Resource - Resource detection utility for automatically configuring OpenTelemetry service metadata.
- EnvResource
Detector - EnvResourceDetector extract resource from environment variable
OTEL_RESOURCE_ATTRIBUTES
. See OpenTelemetry Resource Spec for details. - Key
- The key part of attribute KeyValue pairs.
- KeyValue
- A key-value pair describing an attribute.
- Open
Telemetry Layer - An OpenTelemetry propagation layer for use in a project that uses tracing.
- Resource
- An immutable representation of the entity producing telemetry as attributes.
Utilizes
Arc
for efficient sharing and cloning. - String
Value - Wrapper for string-like values
- Telemetry
Resource Detector - Detect the telemetry SDK information used to capture data recorded by the instrumentation libraries.
- Tracer
Provider - Creator and registry of named
SdkTracer
instances.
Enums§
- Array
- A Value::Array containing homogeneous values.
- OTel
SdkError - Errors that can occur during SDK operations export(), force_flush() and shutdown().
- Value
- The value part of attribute KeyValue pairs.
Traits§
- Open
Telemetry Span Ext - Utility functions to allow tracing
Span
s to accept and return OpenTelemetryContext
s. - Resource
Detector - ResourceDetector detects OpenTelemetry resource information
Functions§
- init_
tracing_ with_ fallbacks - Initializes tracing with OpenTelemetry integration and fallback service information.
- shutdown_
tracer_ provider - Properly shuts down a tracer provider, flushing pending spans and cleaning up resources.