@@ -35,83 +35,74 @@ pub enum Propagator {
3535 Jaeger ,
3636}
3737
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 ( ) )
4041}
4142
4243/// Exporter to use when exporting traces
4344#[ 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 {
4748 /// Don't export traces
49+ #[ default]
4850 None ,
4951
5052 /// Export traces to the standard output. Only useful for debugging
5153 Stdout ,
5254
5355 /// 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 ,
6657}
6758
6859/// Configuration related to exporting traces
6960#[ derive( Clone , Debug , Default , Serialize , Deserialize , JsonSchema ) ]
7061pub struct TracingConfig {
7162 /// 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 > ,
7470
7571 /// List of propagation formats to use for incoming and outgoing requests
7672 pub propagators : Vec < Propagator > ,
7773}
7874
7975/// Exporter to use when exporting metrics
8076#[ 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 {
8480 /// Don't export metrics
81+ #[ default]
8582 None ,
8683
8784 /// Export metrics to stdout. Only useful for debugging
8885 Stdout ,
8986
9087 /// 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 ,
9789
9890 /// Export metrics via Prometheus. An HTTP listener with the `prometheus`
9991 /// resource must be setup to expose the Promethes metrics.
10092 Prometheus ,
10193}
10294
103- impl Default for MetricsExporterConfig {
104- fn default ( ) -> Self {
105- Self :: None
106- }
107- }
108-
10995/// Configuration related to exporting metrics
11096#[ derive( Clone , Debug , Default , Serialize , Deserialize , JsonSchema ) ]
11197pub struct MetricsConfig {
11298 /// 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 > ,
115106}
116107
117108fn sentry_dsn_example ( ) -> & ' static str {
@@ -123,7 +114,7 @@ fn sentry_dsn_example() -> &'static str {
123114pub struct SentryConfig {
124115 /// Sentry DSN
125116 #[ schemars( url, example = "sentry_dsn_example" ) ]
126- #[ serde( default ) ]
117+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
127118 pub dsn : Option < String > ,
128119}
129120
0 commit comments