@@ -80,6 +80,14 @@ pub struct Config {
8080 #[ arg( long, env = "OTEL_GRPC_ENDPOINT_URL" ) ]
8181 pub otel_grpc_endpoint_url : Option < String > ,
8282
83+ /// Export metrics via OTLP gRPC (requires otel_grpc_endpoint_url)
84+ #[ arg( long, env = "OTEL_EXPORT_METRICS" , default_value_t = false , action = clap:: ArgAction :: Set ) ]
85+ pub otel_export_metrics : bool ,
86+
87+ /// Export logs via OTLP gRPC (requires otel_grpc_endpoint_url)
88+ #[ arg( long, env = "OTEL_EXPORT_LOGS" , default_value_t = false , action = clap:: ArgAction :: Set ) ]
89+ pub otel_export_logs : bool ,
90+
8391 /// Prometheus textfile collector directory
8492 #[ arg( long, env = "PROMETHEUS_TEXTFILE_DIR" ) ]
8593 pub prometheus_textfile_dir : Option < String > ,
@@ -114,6 +122,14 @@ impl Config {
114122 if self . worker_threads == 0 {
115123 panic ! ( "Invalid configuration: worker_threads must be greater than 0" ) ;
116124 }
125+
126+ if ( self . otel_export_metrics || self . otel_export_logs )
127+ && self . otel_grpc_endpoint_url . is_none ( )
128+ {
129+ panic ! (
130+ "Invalid configuration: otel_export_metrics and otel_export_logs require otel_grpc_endpoint_url to be set"
131+ ) ;
132+ }
117133 }
118134}
119135
@@ -123,7 +139,8 @@ impl Display for Config {
123139 f,
124140 "Config{{ listen_addr: {}, upstream_endpoint: {}, upstream_region: {}, \
125141 cache_max_entries: {}, cache_max_size_bytes: {}, cache_ttl_seconds: {}, \
126- max_cacheable_object_size: {}, otel_grpc_endpoint_url: {:?}, cache_shards: {}, \
142+ max_cacheable_object_size: {}, otel_grpc_endpoint_url: {:?}, \
143+ otel_export_metrics: {}, otel_export_logs: {}, cache_shards: {}, \
127144 cache_dry_run: {}, worker_threads: {}, prometheus_textfile_dir: {:?} }}",
128145 self . listen_addr,
129146 self . upstream_endpoint,
@@ -133,6 +150,8 @@ impl Display for Config {
133150 self . cache_ttl_seconds,
134151 self . cache_max_object_size_bytes,
135152 self . otel_grpc_endpoint_url,
153+ self . otel_export_metrics,
154+ self . otel_export_logs,
136155 self . cache_shards,
137156 self . cache_dry_run,
138157 self . worker_threads,
@@ -165,6 +184,8 @@ mod tests {
165184 cache_ttl_seconds : 86_400 ,
166185 worker_threads : 4 ,
167186 otel_grpc_endpoint_url : None ,
187+ otel_export_metrics : false ,
188+ otel_export_logs : false ,
168189 prometheus_textfile_dir : None ,
169190 }
170191 }
@@ -210,4 +231,33 @@ mod tests {
210231 config. worker_threads = 0 ;
211232 config. validate ( ) ;
212233 }
234+
235+ #[ test]
236+ #[ should_panic(
237+ expected = "otel_export_metrics and otel_export_logs require otel_grpc_endpoint_url"
238+ ) ]
239+ fn config_otel_export_metrics_without_endpoint ( ) {
240+ let mut config = minimal_config ( ) ;
241+ config. otel_export_metrics = true ;
242+ config. validate ( ) ;
243+ }
244+
245+ #[ test]
246+ #[ should_panic(
247+ expected = "otel_export_metrics and otel_export_logs require otel_grpc_endpoint_url"
248+ ) ]
249+ fn config_otel_export_logs_without_endpoint ( ) {
250+ let mut config = minimal_config ( ) ;
251+ config. otel_export_logs = true ;
252+ config. validate ( ) ;
253+ }
254+
255+ #[ test]
256+ fn config_otel_export_with_endpoint ( ) {
257+ let mut config = minimal_config ( ) ;
258+ config. otel_grpc_endpoint_url = Some ( "http://localhost:4317" . to_string ( ) ) ;
259+ config. otel_export_metrics = true ;
260+ config. otel_export_logs = true ;
261+ config. validate ( ) ;
262+ }
213263}
0 commit comments