langsmith_rust/
lib.rs

1//! LangSmith Rust - Manual tracing for LangSmith
2//!
3//! This crate provides a Rust implementation for manual tracing to LangSmith,
4//! similar to the Python and TypeScript SDKs.
5
6// Load .env file on module initialization
7fn init_dotenv() {
8    let _ = dotenvy::dotenv();
9}
10
11// Initialize dotenv when the module is loaded
12#[allow(dead_code)]
13static INIT: std::sync::Once = std::sync::Once::new();
14
15pub mod client;
16pub mod config;
17pub mod error;
18pub mod factories;
19pub mod models;
20pub mod observability;
21pub mod strategies;
22pub mod tracing;
23pub mod utils;
24
25// Re-export main types
26pub use client::LangSmithClient;
27pub use config::Config;
28pub use error::{LangSmithError, Result};
29pub use factories::TracerFactory;
30pub use models::{
31    metrics::Metrics,
32    AIMessage, HumanMessage, Message, Run, RunType, RunUpdate, SystemMessage, ToolCall,
33    ToolMessage,
34};
35pub use observability::{LangSmithObserver, Observable, ObservableNodeWrapper, Observer};
36pub use strategies::{SerializationStrategy, TracingStrategy};
37pub use tracing::{trace_node, trace_node_sync, TraceContext, Tracer};
38
39// Initialize dotenv on first use
40pub fn init() {
41    INIT.call_once(|| {
42        init_dotenv();
43    });
44}
45
46#[cfg(test)]
47mod tests {
48    #[test]
49    fn test_module_compiles() {
50        // Verify the module compiles
51        assert!(true);
52    }
53}