Skip to main content

adk_telemetry/
lib.rs

1//! # ADK Telemetry
2//!
3//! Production-grade observability for ADK using structured logging and distributed tracing.
4//!
5//! ## Features
6//! - Structured logging with `tracing`
7//! - OpenTelemetry integration for distributed tracing
8//! - OTLP export for observability backends (Jaeger, Datadog, etc.)
9//! - Automatic context propagation
10//! - OTel GenAI Semantic Conventions (v1.41.0) via `genai-semconv` feature (enabled by default)
11//!
12//! ## Usage
13//!
14//! ```rust
15//! use adk_telemetry::{init_telemetry, info, instrument};
16//!
17//! fn main() -> Result<(), adk_telemetry::TelemetryError> {
18//!     // Initialize telemetry in your main
19//!     init_telemetry("my-service")?;
20//!
21//!     // Use logging macros
22//!     #[instrument]
23//!     async fn my_function() {
24//!         info!("Function called");
25//!     }
26//!     Ok(())
27//! }
28//! ```
29
30pub mod init;
31pub mod span_exporter;
32pub mod spans;
33
34// Direct span export to a local SQLite file (feature-gated)
35#[cfg(feature = "sqlite")]
36pub mod sqlite;
37
38// GenAI Semantic Conventions module (feature-gated)
39#[cfg(feature = "genai-semconv")]
40pub mod semconv;
41
42// Content event configuration (feature-gated)
43#[cfg(feature = "genai-semconv")]
44pub mod config;
45
46// Content event emitter (feature-gated)
47#[cfg(feature = "genai-semconv")]
48pub mod events;
49
50// Re-export tracing macros for convenience
51pub use tracing::{Span, debug, error, info, instrument, trace, warn};
52
53// Re-export span helpers
54pub use spans::*;
55
56// Re-export span exporter (ADK-Go style)
57pub use span_exporter::*;
58
59// Re-export init functions and error type
60#[cfg(feature = "sqlite")]
61pub use init::init_with_sqlite;
62pub use init::{TelemetryError, init_telemetry, init_with_adk_exporter, shutdown_telemetry};
63#[cfg(feature = "otlp")]
64pub use init::{build_otlp_layer, init_with_otlp};
65#[cfg(feature = "sqlite")]
66pub use sqlite::{SessionSummary, SpanRow, SqliteSpanExporter, SqliteTraceReader};
67
68// Re-export metrics
69#[cfg(feature = "otlp")]
70pub use opentelemetry::global;
71#[cfg(feature = "otlp")]
72pub use opentelemetry::metrics::{Meter, MeterProvider};
73
74// Re-export key semconv types for convenience
75#[cfg(feature = "genai-semconv")]
76pub use semconv::{GenAiOperation, GenAiProvider, GenAiResponseRecorder, GenAiSpanBuilder};