frontend/service_config/
otlp.rs1use serde::{Deserialize, Serialize};
16
17const DEFAULT_TRACE_INGEST_CHUNK_SIZE: usize = 512;
18
19#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
20#[serde(default)]
21pub struct OtlpOptions {
22 pub enable: bool,
23 pub experimental_enable_exponential_histogram: bool,
24 pub trace_ingest_chunk_size: usize,
26 pub experimental_enable_resource_info: bool,
31}
32
33impl Default for OtlpOptions {
34 fn default() -> Self {
35 Self {
36 enable: true,
37 experimental_enable_exponential_histogram: false,
38 trace_ingest_chunk_size: DEFAULT_TRACE_INGEST_CHUNK_SIZE,
39 experimental_enable_resource_info: false,
40 }
41 }
42}
43
44#[cfg(test)]
45mod tests {
46 use super::*;
47
48 #[test]
49 fn test_otlp_options() {
50 let default = OtlpOptions::default();
51 assert!(default.enable);
52 assert!(!default.experimental_enable_exponential_histogram);
53 assert_eq!(default.trace_ingest_chunk_size, 512);
54 assert!(!default.experimental_enable_resource_info);
55
56 let options: OtlpOptions = toml::from_str("enable = false").unwrap();
57 assert!(!options.enable);
58 assert!(!options.experimental_enable_exponential_histogram);
59 assert_eq!(
60 options.trace_ingest_chunk_size,
61 DEFAULT_TRACE_INGEST_CHUNK_SIZE
62 );
63
64 let options: OtlpOptions = toml::from_str("trace_ingest_chunk_size = 0").unwrap();
65 assert!(options.enable);
66 assert!(!options.experimental_enable_exponential_histogram);
67 assert_eq!(options.trace_ingest_chunk_size, 0);
68
69 let options: OtlpOptions =
70 toml::from_str("experimental_enable_exponential_histogram = true").unwrap();
71 assert!(options.experimental_enable_exponential_histogram);
72
73 let serialized = toml::to_string(&options).unwrap();
74 assert!(serialized.contains("experimental_enable_exponential_histogram = true"));
75 assert_eq!(toml::from_str::<OtlpOptions>(&serialized).unwrap(), options);
76 }
77}