@@ -93,6 +93,9 @@ impl ZipkinExporterBuilder {
93
93
}
94
94
95
95
/// Assign client implementation
96
+ ///
97
+ /// Note: Programmatically setting the timeout will override any value
98
+ /// set via the environment variable `OTEL_EXPORTER_ZIPKIN_TIMEOUT`.
96
99
pub fn with_http_client < T : HttpClient + ' static > ( mut self , client : T ) -> Self {
97
100
self . client = Some ( Arc :: new ( client) ) ;
98
101
self
@@ -105,6 +108,9 @@ impl ZipkinExporterBuilder {
105
108
}
106
109
107
110
/// Assign the Zipkin collector endpoint
111
+ ///
112
+ /// Note: Programmatically setting this will override any value
113
+ /// set via the environment variable `OTEL_EXPORTER_ZIPKIN_ENDPOINT`.
108
114
pub fn with_collector_endpoint < T : Into < String > > ( mut self , endpoint : T ) -> Self {
109
115
self . collector_endpoint = endpoint. into ( ) ;
110
116
self
@@ -161,3 +167,29 @@ impl ExportError for Error {
161
167
"zipkin"
162
168
}
163
169
}
170
+
171
+ #[ cfg( test) ]
172
+ mod tests {
173
+ use super :: * ;
174
+ use crate :: exporter:: env:: ENV_ENDPOINT ;
175
+
176
+ #[ test]
177
+ fn test_priority_of_code_based_config_over_envs_for_endpoint ( ) {
178
+ temp_env:: with_vars ( [ ( ENV_ENDPOINT , Some ( "http://127.0.0.1:1234" ) ) ] , || {
179
+ let builder =
180
+ ZipkinExporterBuilder :: default ( ) . with_collector_endpoint ( "http://127.0.0.1:2345" ) ;
181
+ assert_eq ! ( builder. collector_endpoint, "http://127.0.0.1:2345" ) ;
182
+ } ) ;
183
+ }
184
+
185
+ #[ test]
186
+ fn test_use_default_when_others_missing_for_endpoint ( ) {
187
+ temp_env:: with_vars ( [ ( ENV_ENDPOINT , None :: < & str > ) ] , || {
188
+ let builder = ZipkinExporterBuilder :: default ( ) ;
189
+ assert_eq ! (
190
+ builder. collector_endpoint,
191
+ "http://127.0.0.1:9411/api/v2/spans"
192
+ ) ;
193
+ } ) ;
194
+ }
195
+ }
0 commit comments