File tree Expand file tree Collapse file tree 2 files changed +23
-11
lines changed Expand file tree Collapse file tree 2 files changed +23
-11
lines changed Original file line number Diff line number Diff line change @@ -25,11 +25,13 @@ impl wasi_otel::Host for InstanceState {
25
25
26
26
// Before we ever create any new spans make sure we track the original host span ID
27
27
if state. original_host_span_id . is_none ( ) {
28
- // TODO: Note this is also failing to get anything meaningful through tracing::Span::current()
29
- let context = dbg ! ( tracing:: Span :: current( ) . context( ) ) ;
30
- let span = dbg ! ( context. span( ) ) ;
31
- let span_context = dbg ! ( span. span_context( ) ) ;
32
- state. original_host_span_id = dbg ! ( Some ( span_context. span_id( ) ) ) ;
28
+ state. original_host_span_id = Some (
29
+ tracing:: Span :: current ( )
30
+ . context ( )
31
+ . span ( )
32
+ . span_context ( )
33
+ . span_id ( ) ,
34
+ ) ;
33
35
}
34
36
35
37
// // Get span's parent based on whether it's a new root and whether there are any active spans
@@ -105,12 +107,12 @@ impl wasi_otel::Host for InstanceState {
105
107
}
106
108
107
109
async fn current_span_context ( & mut self ) -> Result < wasi_otel:: SpanContext > {
108
- // TODO: The bug is that tracing::Span::current() is not returning anything
109
- let context = dbg ! ( dbg! ( tracing :: Span :: current ( ) ) . context( ) ) ;
110
- let span = context . span ( ) ;
111
- let span_context = span . span_context ( ) ;
112
- let out : SpanContext = span_context . clone ( ) . into ( ) ;
113
- Ok ( out )
110
+ Ok ( tracing:: Span :: current ( )
111
+ . context ( )
112
+ . span ( )
113
+ . span_context ( )
114
+ . clone ( )
115
+ . into ( ) )
114
116
}
115
117
}
116
118
Original file line number Diff line number Diff line change @@ -48,6 +48,15 @@ pub use propagation::inject_trace_context;
48
48
/// spin_telemetry::metrics::monotonic_counter!(spin.metric_name = 1, metric_attribute = "value");
49
49
/// ```
50
50
pub fn init ( spin_version : String ) -> anyhow:: Result < ShutdownGuard > {
51
+ // This filter globally filters out spans produced by wasi_http so that they don't conflict with
52
+ // the behaviour of the wasi-otel factor.
53
+ let wasi_http_trace_filter = tracing_subscriber:: filter:: filter_fn ( |metadata| {
54
+ if metadata. is_span ( ) && metadata. name ( ) == "wit-bindgen export" {
55
+ return false ;
56
+ }
57
+ true
58
+ } ) ;
59
+
51
60
// This layer will print all tracing library log messages to stderr.
52
61
let fmt_layer = fmt:: layer ( )
53
62
. with_writer ( std:: io:: stderr)
@@ -78,6 +87,7 @@ pub fn init(spin_version: String) -> anyhow::Result<ShutdownGuard> {
78
87
79
88
// Build a registry subscriber with the layers we want to use.
80
89
registry ( )
90
+ . with ( wasi_http_trace_filter)
81
91
. with ( otel_tracing_layer)
82
92
. with ( otel_metrics_layer)
83
93
. with ( fmt_layer)
You can’t perform that action at this time.
0 commit comments