File tree 2 files changed +31
-5
lines changed 2 files changed +31
-5
lines changed Original file line number Diff line number Diff line change 1
1
use crate :: propagation:: TextMapPropagator ;
2
- use crate :: sdk:: propagation:: {
3
- BaggagePropagator , TextMapCompositePropagator , TraceContextPropagator ,
4
- } ;
2
+ use crate :: sdk:: propagation:: TextMapCompositePropagator ;
5
3
use std:: sync:: RwLock ;
6
4
7
5
lazy_static:: lazy_static! {
8
6
/// The current global `TextMapPropagator` propagator.
9
- static ref GLOBAL_TEXT_MAP_PROPAGATOR : RwLock <Box <dyn TextMapPropagator + Send + Sync >> = RwLock :: new( Box :: new( TextMapCompositePropagator :: new( vec![ Box :: new ( TraceContextPropagator :: new ( ) ) , Box :: new ( BaggagePropagator :: new ( ) ) ] ) ) ) ;
7
+ static ref GLOBAL_TEXT_MAP_PROPAGATOR : RwLock <Box <dyn TextMapPropagator + Send + Sync >> = RwLock :: new( Box :: new( TextMapCompositePropagator :: new( vec![ ] ) ) ) ;
10
8
/// The global default `TextMapPropagator` propagator.
11
- static ref DEFAULT_TEXT_MAP_PROPAGATOR : TextMapCompositePropagator = TextMapCompositePropagator :: new( vec![ Box :: new ( TraceContextPropagator :: new ( ) ) , Box :: new ( BaggagePropagator :: new ( ) ) ] ) ;
9
+ static ref DEFAULT_TEXT_MAP_PROPAGATOR : TextMapCompositePropagator = TextMapCompositePropagator :: new( vec![ ] ) ;
12
10
}
13
11
14
12
/// Sets the given [`TextMapPropagator`] propagator as the current global propagator.
Original file line number Diff line number Diff line change @@ -186,6 +186,34 @@ mod tests {
186
186
]
187
187
}
188
188
189
+ #[ test]
190
+ fn zero_propogators_are_noop ( ) {
191
+ let composite_propagator = TextMapCompositePropagator :: new ( vec ! [ ] ) ;
192
+
193
+ let cx = Context :: default ( ) . with_span ( TestSpan ( SpanContext :: new (
194
+ TraceId :: from_u128 ( 1 ) ,
195
+ SpanId :: from_u64 ( 1 ) ,
196
+ 0 ,
197
+ false ,
198
+ TraceState :: default ( ) ,
199
+ ) ) ) ;
200
+ let mut injector = HashMap :: new ( ) ;
201
+ composite_propagator. inject_context ( & cx, & mut injector) ;
202
+
203
+ assert_eq ! ( injector. len( ) , 0 ) ;
204
+
205
+ for ( header_name, header_value) in test_data ( ) {
206
+ let mut extractor = HashMap :: new ( ) ;
207
+ extractor. insert ( header_name. to_string ( ) , header_value. to_string ( ) ) ;
208
+ assert_eq ! (
209
+ composite_propagator
210
+ . extract( & extractor)
211
+ . remote_span_context( ) ,
212
+ None
213
+ ) ;
214
+ }
215
+ }
216
+
189
217
#[ test]
190
218
fn inject_multiple_propagators ( ) {
191
219
let test_propagator = TestPropagator :: new ( ) ;
You can’t perform that action at this time.
0 commit comments