Skip to content

Commit c9b29b0

Browse files
committed
Finish two easy impls
Signed-off-by: Caleb Schoepp <[email protected]>
1 parent 47db742 commit c9b29b0

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

crates/factor-observe/src/host.rs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use opentelemetry::trace::Tracer;
99
use opentelemetry::Context;
1010
use spin_core::async_trait;
1111
use spin_core::wasmtime::component::Resource;
12-
use spin_world::wasi::clocks0_2_0::wall_clock;
1312
use spin_world::wasi::observe::traces::Datetime;
1413
use spin_world::wasi::observe::traces::{self, KeyValue, Span as WitSpan};
1514
use tracing_opentelemetry::OpenTelemetrySpanExt;
@@ -75,8 +74,13 @@ impl traces::HostSpan for InstanceState {
7574
todo!()
7675
}
7776

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+
}
8084
}
8185

8286
async fn set_attributes(
@@ -130,7 +134,7 @@ impl traces::HostSpan for InstanceState {
130134

131135
guest_span
132136
.inner
133-
.add_event_with_timestamp(name.into(), timestamp, attributes)
137+
.add_event_with_timestamp(name.into(), timestamp, attributes);
134138
} else {
135139
tracing::debug!("can't find guest span to add events too")
136140
}
@@ -149,8 +153,19 @@ impl traces::HostSpan for InstanceState {
149153
todo!()
150154
}
151155

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(())
154169
}
155170

156171
async fn end(

0 commit comments

Comments
 (0)