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 {
2525
2626 // Before we ever create any new spans make sure we track the original host span ID
2727 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+ ) ;
3335 }
3436
3537 // // 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 {
105107 }
106108
107109 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 ( ) )
114116 }
115117}
116118
Original file line number Diff line number Diff line change @@ -48,6 +48,15 @@ pub use propagation::inject_trace_context;
4848/// spin_telemetry::metrics::monotonic_counter!(spin.metric_name = 1, metric_attribute = "value");
4949/// ```
5050pub 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+
5160 // This layer will print all tracing library log messages to stderr.
5261 let fmt_layer = fmt:: layer ( )
5362 . with_writer ( std:: io:: stderr)
@@ -78,6 +87,7 @@ pub fn init(spin_version: String) -> anyhow::Result<ShutdownGuard> {
7887
7988 // Build a registry subscriber with the layers we want to use.
8089 registry ( )
90+ . with ( wasi_http_trace_filter)
8191 . with ( otel_tracing_layer)
8292 . with ( otel_metrics_layer)
8393 . with ( fmt_layer)
You can’t perform that action at this time.
0 commit comments