Crate telemetry_rust

Source
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
  • Integration testing tools

§Available Feature Flags

  • axum: Axum web framework middleware support
  • aws-span: AWS SDK span creation utilities
  • aws-instrumentation: Instrumentation for AWS SDK operations
  • aws-stream-instrumentation: Instrumentation for AWS SDK pagination streams
  • aws-lambda: AWS Lambda runtime middleware
  • aws: All AWS features (span + instrumentation + stream instrumentation)
  • aws-full: All AWS features including Lambda
  • future: Future instrumentation utilities
  • test: Testing utilities for OpenTelemetry validation
  • zipkin: Zipkin context propagation support (enabled by default)
  • full: 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§

pub use tracing_opentelemetry_instrumentation_sdk;

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.
DetectResource
Resource detection utility for automatically configuring OpenTelemetry service metadata.
EnvResourceDetector
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.
OpenTelemetryLayer
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.
StringValue
Wrapper for string-like values
TelemetryResourceDetector
Detect the telemetry SDK information used to capture data recorded by the instrumentation libraries.
TracerProvider
Creator and registry of named SdkTracer instances.

Enums§

Array
A Value::Array containing homogeneous values.
OTelSdkError
Errors that can occur during SDK operations export(), force_flush() and shutdown().
Value
The value part of attribute KeyValue pairs.

Traits§

OpenTelemetrySpanExt
Utility functions to allow tracing Spans to accept and return OpenTelemetry Contexts.
ResourceDetector
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.