File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 4
4
5
5
use opentelemetry:: propagation:: { Extractor , Injector } ;
6
6
use opentelemetry:: Context ;
7
+ use tracing_opentelemetry_instrumentation_sdk as otel;
7
8
8
9
// copy from crate opentelemetry-http (to not be dependants of on 3rd: http, ...)
9
10
pub struct HeaderInjector < ' a > ( pub & ' a mut http:: HeaderMap ) ;
@@ -36,13 +37,20 @@ impl<'a> Extractor for HeaderExtractor<'a> {
36
37
}
37
38
}
38
39
39
- pub fn inject_context ( context : & Context , headers : & mut http:: HeaderMap ) {
40
+ pub fn inject_context_on_context ( context : & Context , headers : & mut http:: HeaderMap ) {
40
41
let mut injector = HeaderInjector ( headers) ;
41
42
opentelemetry:: global:: get_text_map_propagator ( |propagator| {
42
43
propagator. inject_context ( context, & mut injector) ;
43
44
} ) ;
44
45
}
45
46
47
+ pub fn inject_context ( headers : & mut http:: HeaderMap ) {
48
+ let mut injector = HeaderInjector ( headers) ;
49
+ opentelemetry:: global:: get_text_map_propagator ( |propagator| {
50
+ propagator. inject_context ( & otel:: find_current_context ( ) , & mut injector) ;
51
+ } ) ;
52
+ }
53
+
46
54
// If remote request has no span data the propagator defaults to an unsampled context
47
55
#[ must_use]
48
56
pub fn extract_context ( headers : & http:: HeaderMap ) -> Context {
You can’t perform that action at this time.
0 commit comments