autoagents_telemetry/
config.rs1use autoagents_protocol::RuntimeID;
2use std::collections::HashMap;
3
4#[derive(Debug, Clone)]
6pub struct TelemetryConfig {
7 pub service_name: String,
8 pub service_version: Option<String>,
9 pub environment: Option<String>,
10 pub runtime_id: Option<RuntimeID>,
11 pub exporter: ExporterConfig,
12 pub span_batch: SpanBatchConfig,
13 pub redaction: RedactionConfig,
14 pub metrics_enabled: bool,
15 pub install_tracing_subscriber: bool,
16}
17
18impl TelemetryConfig {
19 pub fn new(service_name: impl Into<String>) -> Self {
20 Self {
21 service_name: service_name.into(),
22 service_version: None,
23 environment: None,
24 runtime_id: None,
25 exporter: ExporterConfig::default(),
26 span_batch: SpanBatchConfig::default(),
27 redaction: RedactionConfig::default(),
28 metrics_enabled: true,
29 install_tracing_subscriber: true,
30 }
31 }
32
33 pub fn with_runtime_id(mut self, runtime_id: RuntimeID) -> Self {
34 self.runtime_id = Some(runtime_id);
35 self
36 }
37}
38
39impl Default for TelemetryConfig {
40 fn default() -> Self {
41 Self {
42 service_name: "autoagents".into(),
43 service_version: None,
44 environment: None,
45 runtime_id: None,
46 exporter: ExporterConfig::default(),
47 span_batch: SpanBatchConfig::default(),
48 redaction: RedactionConfig::default(),
49 metrics_enabled: true,
50 install_tracing_subscriber: true,
51 }
52 }
53}
54
55#[derive(Debug, Clone, Default)]
57pub struct ExporterConfig {
58 pub otlp: Option<OtlpConfig>,
59 pub stdout: bool,
60}
61
62#[derive(Debug, Clone)]
64pub struct SpanBatchConfig {
65 pub max_queue_size: usize,
66 pub max_export_batch_size: usize,
67 pub scheduled_delay: std::time::Duration,
68 pub max_export_timeout: std::time::Duration,
69 pub max_concurrent_exports: usize,
70}
71
72impl Default for SpanBatchConfig {
73 fn default() -> Self {
74 Self {
75 max_queue_size: 2048,
76 max_export_batch_size: 512,
77 scheduled_delay: std::time::Duration::from_secs(5),
78 max_export_timeout: std::time::Duration::from_secs(30),
79 max_concurrent_exports: 1,
80 }
81 }
82}
83
84#[derive(Debug, Clone)]
86pub struct OtlpConfig {
87 pub endpoint: Option<String>,
88 pub protocol: OtlpProtocol,
89 pub headers: HashMap<String, String>,
90 pub debug_http: bool,
91}
92
93impl OtlpConfig {
94 pub fn new(endpoint: impl Into<String>) -> Self {
95 Self {
96 endpoint: Some(endpoint.into()),
97 protocol: OtlpProtocol::HttpBinary,
98 headers: HashMap::new(),
99 debug_http: false,
100 }
101 }
102}
103
104impl Default for OtlpConfig {
105 fn default() -> Self {
106 Self {
107 endpoint: None,
108 protocol: OtlpProtocol::HttpBinary,
109 headers: HashMap::new(),
110 debug_http: false,
111 }
112 }
113}
114
115#[derive(Debug, Clone, Copy)]
117pub enum OtlpProtocol {
118 HttpBinary,
119 HttpJson,
120}
121
122#[derive(Debug, Clone, Default)]
124pub struct RedactionConfig {
125 pub redact_task_inputs: bool,
126 pub redact_task_outputs: bool,
127 pub redact_tool_arguments: bool,
128 pub redact_tool_results: bool,
129}