@@ -9,7 +9,6 @@ use opentelemetry::trace::Tracer;
9
9
use opentelemetry:: Context ;
10
10
use spin_core:: async_trait;
11
11
use spin_core:: wasmtime:: component:: Resource ;
12
- use spin_world:: wasi:: clocks0_2_0:: wall_clock;
13
12
use spin_world:: wasi:: observe:: traces:: Datetime ;
14
13
use spin_world:: wasi:: observe:: traces:: { self , KeyValue , Span as WitSpan } ;
15
14
use tracing_opentelemetry:: OpenTelemetrySpanExt ;
@@ -75,8 +74,13 @@ impl traces::HostSpan for InstanceState {
75
74
todo ! ( )
76
75
}
77
76
78
- async fn is_recording ( & mut self , _resource : Resource < WitSpan > ) -> Result < bool > {
79
- todo ! ( )
77
+ async fn is_recording ( & mut self , resource : Resource < WitSpan > ) -> Result < bool > {
78
+ if let Some ( guest_span) = self . state . read ( ) . unwrap ( ) . guest_spans . get ( resource. rep ( ) ) {
79
+ Ok ( guest_span. inner . is_recording ( ) )
80
+ } else {
81
+ tracing:: debug!( "can't find guest span to read" ) ;
82
+ Err ( anyhow:: anyhow!( "can't find guest span to read" ) )
83
+ }
80
84
}
81
85
82
86
async fn set_attributes (
@@ -130,7 +134,7 @@ impl traces::HostSpan for InstanceState {
130
134
131
135
guest_span
132
136
. inner
133
- . add_event_with_timestamp ( name. into ( ) , timestamp, attributes)
137
+ . add_event_with_timestamp ( name. into ( ) , timestamp, attributes) ;
134
138
} else {
135
139
tracing:: debug!( "can't find guest span to add events too" )
136
140
}
@@ -149,8 +153,19 @@ impl traces::HostSpan for InstanceState {
149
153
todo ! ( )
150
154
}
151
155
152
- async fn update_name ( & mut self , _resource : Resource < WitSpan > , _name : String ) -> Result < ( ) > {
153
- todo ! ( )
156
+ async fn update_name ( & mut self , resource : Resource < WitSpan > , name : String ) -> Result < ( ) > {
157
+ if let Some ( guest_span) = self
158
+ . state
159
+ . write ( )
160
+ . unwrap ( )
161
+ . guest_spans
162
+ . get_mut ( resource. rep ( ) )
163
+ {
164
+ guest_span. inner . update_name ( name. into ( ) ) ;
165
+ } else {
166
+ tracing:: debug!( "can't find guest span to set name on" )
167
+ }
168
+ Ok ( ( ) )
154
169
}
155
170
156
171
async fn end (
0 commit comments