otlp_arrow_library/lib.rs
1//! OTLP Arrow Flight Library
2//!
3//! A cross-platform Rust library for receiving OpenTelemetry Protocol (OTLP) messages
4//! via gRPC and writing them to local files in Arrow IPC Streaming format.
5//!
6//! # Features
7//!
8//! - OTLP gRPC reception
9//! - Arrow IPC file storage
10//! - Public API for embedded usage
11//! - Configurable via YAML, environment variables, or programmatic API
12//! - Optional remote forwarding
13//! - Mock service for testing
14//!
15//! # Example
16//!
17//! ```no_run
18//! use otlp_arrow_library::{OtlpLibrary, Config};
19//!
20//! # async fn example() -> Result<(), otlp_arrow_library::OtlpError> {
21//! let config = Config::default();
22//! let library = OtlpLibrary::new(config).await?;
23//!
24//! // Export traces
25//! // library.export_trace(span).await?;
26//! # Ok(())
27//! # }
28//! ```
29
30#![warn(missing_docs)]
31#![warn(clippy::all)]
32
33pub mod api;
34pub mod config;
35pub mod dashboard;
36pub mod error;
37pub mod mock;
38pub mod otlp;
39
40// Python module - only compiled when python-extension feature is enabled
41// This prevents linker errors during cargo test when Python isn't available
42#[cfg(feature = "python-extension")]
43pub mod python;
44
45// Re-export public API
46pub use api::public::OtlpLibrary;
47pub use config::{
48 AuthConfig, Config, ConfigBuilder, DashboardConfig, ForwardingConfig, ForwardingProtocol,
49};
50pub use error::{OtlpConfigError, OtlpError, OtlpExportError, OtlpServerError};
51pub use mock::service::MockOtlpService;
52pub use otlp::OtlpSpanExporter;
53
54// Re-export Python module function for maturin to find
55// This makes the #[pymodule] function accessible at crate root level
56// Only available when python-extension feature is enabled
57#[cfg(feature = "python-extension")]
58pub use python::otlp_arrow_library;
59
60// Initialize tracing subscriber for structured logging
61use tracing_subscriber::EnvFilter;
62
63/// Initialize structured logging
64pub fn init_logging() {
65 tracing_subscriber::fmt()
66 .with_env_filter(EnvFilter::from_default_env())
67 .with_target(false)
68 .with_thread_ids(false)
69 .with_thread_names(false)
70 .init();
71}
72
73#[cfg(test)]
74mod tests {
75 use super::*;
76
77 #[test]
78 fn test_library_initialization() {
79 init_logging();
80 // Basic smoke test - just verify logging initializes without panicking
81 }
82}