1#![deny(warnings)]
2
3extern crate tracelite_macro;
4
5pub use tracelite_macro::*;
6
7mod spinlock;
8
9mod severity;
10pub use severity::{Severity, SeverityParseError};
11
12mod attributes;
13pub use attributes::AttributeValue;
14
15mod tracer;
16pub use tracer::*;
17pub use tracer::globals::*;
18
19mod record_exception;
20pub use record_exception::{RecordException, RecordExceptionDebugFmt};
21
22mod default_tracer;
23pub use default_tracer::{DefaultTracer, DefaultTracerConfig};
24
25pub mod clocks;
26pub mod id_generators;
27pub mod sampling;
28pub mod span_collections;
29pub mod export;
30
31mod macros;
32
33pub fn install_tracer_micropb_tokio_h2grpc(
34 env_var: &str,
35 (service_name, service_attributes): (&str, AttributeList),
36 otlp_endpoint: &str,
37 tracer_autoflush_interval: std::time::Duration,
38){
39 use self::clocks::StdClock;
40 use self::id_generators::FastrandIdGenerator;
41 use self::sampling::{AlwaysSampler, EnvSampler};
42 use self::span_collections::OtlpMicroPbConfig;
43
44 DefaultTracerConfig::new(
45 StdClock,
46 FastrandIdGenerator,
47 EnvSampler::from_env(env_var),
48 AlwaysSampler,
49 OtlpMicroPbConfig::new(service_name, service_attributes)
50 .build(),
51 export::spawn_tokio_export_task(
52 export::H2GrpcExport::new(otlp_endpoint).unwrap(),
53 tracer_autoflush_interval,
54 )
55 ).install();
56}
57
58use self::clocks::TestClock;
59use self::sampling::Sampler;
60use self::export::TestExport;
61
62pub fn install_tracer_micropb_tokio_test(
63 rust_trace_env: &str,
64 (service_name, service_attributes): (&str, AttributeList),
65 tracer_autoflush_interval: std::time::Duration,
66 sampler: impl Sampler,
67) -> (TestClock, TestExport) {
68 use self::sampling::EnvSampler;
69 use self::id_generators::TestIdGenerator;
70 use self::span_collections::OtlpMicroPbConfig;
71
72 let test_clock = TestClock::default();
73 let test_export = TestExport::default();
74
75 DefaultTracerConfig::new(
76 test_clock.clone(),
77 TestIdGenerator::default(),
78 EnvSampler::new(Some(rust_trace_env.to_owned())),
79 sampler,
80 OtlpMicroPbConfig::new(service_name, service_attributes)
81 .build(),
82 export::spawn_tokio_export_task(
83 test_export.clone(),
84 tracer_autoflush_interval,
85 )
86 ).install();
87
88 (test_clock, test_export)
89}