@@ -35,83 +35,74 @@ pub enum Propagator {
35
35
Jaeger ,
36
36
}
37
37
38
- fn otlp_endpoint_example ( ) -> & ' static str {
39
- "https://localhost:4318"
38
+ #[ allow( clippy:: unnecessary_wraps) ]
39
+ fn otlp_endpoint_default ( ) -> Option < String > {
40
+ Some ( "https://localhost:4318" . to_owned ( ) )
40
41
}
41
42
42
43
/// Exporter to use when exporting traces
43
44
#[ skip_serializing_none]
44
- #[ derive( Clone , Debug , Serialize , Deserialize , JsonSchema ) ]
45
- #[ serde( tag = "exporter" , rename_all = "lowercase" , deny_unknown_fields ) ]
46
- pub enum TracingExporterConfig {
45
+ #[ derive( Clone , Copy , Debug , Serialize , Deserialize , JsonSchema , Default ) ]
46
+ #[ serde( rename_all = "lowercase" ) ]
47
+ pub enum TracingExporterKind {
47
48
/// Don't export traces
49
+ #[ default]
48
50
None ,
49
51
50
52
/// Export traces to the standard output. Only useful for debugging
51
53
Stdout ,
52
54
53
55
/// Export traces to an OpenTelemetry protocol compatible endpoint
54
- Otlp {
55
- /// OTLP compatible endpoint
56
- #[ schemars( url, example = "otlp_endpoint_example" ) ]
57
- #[ serde( default ) ]
58
- endpoint : Option < Url > ,
59
- } ,
60
- }
61
-
62
- impl Default for TracingExporterConfig {
63
- fn default ( ) -> Self {
64
- Self :: None
65
- }
56
+ Otlp ,
66
57
}
67
58
68
59
/// Configuration related to exporting traces
69
60
#[ derive( Clone , Debug , Default , Serialize , Deserialize , JsonSchema ) ]
70
61
pub struct TracingConfig {
71
62
/// Exporter to use when exporting traces
72
- #[ serde( default , flatten) ]
73
- pub exporter : TracingExporterConfig ,
63
+ #[ serde( default ) ]
64
+ pub exporter : TracingExporterKind ,
65
+
66
+ /// OTLP exporter: OTLP over HTTP compatible endpoint
67
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
68
+ #[ schemars( url, default = "otlp_endpoint_default" ) ]
69
+ pub endpoint : Option < Url > ,
74
70
75
71
/// List of propagation formats to use for incoming and outgoing requests
76
72
pub propagators : Vec < Propagator > ,
77
73
}
78
74
79
75
/// Exporter to use when exporting metrics
80
76
#[ skip_serializing_none]
81
- #[ derive( Clone , Debug , Serialize , Deserialize , JsonSchema ) ]
82
- #[ serde( tag = "exporter" , rename_all = "lowercase" ) ]
83
- pub enum MetricsExporterConfig {
77
+ #[ derive( Clone , Copy , Debug , Serialize , Deserialize , JsonSchema , Default ) ]
78
+ #[ serde( rename_all = "lowercase" ) ]
79
+ pub enum MetricsExporterKind {
84
80
/// Don't export metrics
81
+ #[ default]
85
82
None ,
86
83
87
84
/// Export metrics to stdout. Only useful for debugging
88
85
Stdout ,
89
86
90
87
/// Export metrics to an OpenTelemetry protocol compatible endpoint
91
- Otlp {
92
- /// OTLP compatible endpoint
93
- #[ schemars( url, example = "otlp_endpoint_example" ) ]
94
- #[ serde( default ) ]
95
- endpoint : Option < Url > ,
96
- } ,
88
+ Otlp ,
97
89
98
90
/// Export metrics via Prometheus. An HTTP listener with the `prometheus`
99
91
/// resource must be setup to expose the Promethes metrics.
100
92
Prometheus ,
101
93
}
102
94
103
- impl Default for MetricsExporterConfig {
104
- fn default ( ) -> Self {
105
- Self :: None
106
- }
107
- }
108
-
109
95
/// Configuration related to exporting metrics
110
96
#[ derive( Clone , Debug , Default , Serialize , Deserialize , JsonSchema ) ]
111
97
pub struct MetricsConfig {
112
98
/// Exporter to use when exporting metrics
113
- #[ serde( default , flatten) ]
114
- pub exporter : MetricsExporterConfig ,
99
+ #[ serde( default ) ]
100
+ pub exporter : MetricsExporterKind ,
101
+
102
+ /// OTLP exporter: OTLP over HTTP compatible endpoint
103
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
104
+ #[ schemars( url, default = "otlp_endpoint_default" ) ]
105
+ pub endpoint : Option < Url > ,
115
106
}
116
107
117
108
fn sentry_dsn_example ( ) -> & ' static str {
@@ -123,7 +114,7 @@ fn sentry_dsn_example() -> &'static str {
123
114
pub struct SentryConfig {
124
115
/// Sentry DSN
125
116
#[ schemars( url, example = "sentry_dsn_example" ) ]
126
- #[ serde( default ) ]
117
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
127
118
pub dsn : Option < String > ,
128
119
}
129
120
0 commit comments