Skip to content

Commit 5fddcff

Browse files
committed
Small changes and TODOs
Signed-off-by: Caleb Schoepp <caleb.schoepp@fermyon.com>
1 parent a5f6d2a commit 5fddcff

File tree

5 files changed

+11
-10
lines changed

5 files changed

+11
-10
lines changed

crates/factor-observe/src/lib.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,15 @@ pub struct InstanceState {
5757
impl SelfInstanceBuilder for InstanceState {}
5858

5959
impl InstanceState {
60+
/// TODO comment
6061
pub fn get_observe_context(&self) -> ObserveContext {
6162
ObserveContext {
6263
state: self.state.clone(),
6364
}
6465
}
6566
}
6667

67-
/// Internal state of the observe host component.
68+
/// Internal state of the observe factor.
6869
pub(crate) struct State {
6970
/// A resource table that holds the guest spans.
7071
pub guest_spans: table::Table<GuestSpan>,
@@ -83,14 +84,16 @@ pub struct GuestSpan {
8384
pub inner: opentelemetry_sdk::trace::Span,
8485
}
8586

87+
/// TODO comment
8688
pub struct ObserveContext {
8789
pub(crate) state: Arc<RwLock<State>>,
8890
}
8991

9092
impl ObserveContext {
9193
/// TODO comment
9294
/// Make sure to mention this should only be called from an instrumented function in a factor.
93-
pub fn reparent_tracing_span_this_was_lanns_idea(&self) {
95+
/// Make sure this is called before any awaits
96+
pub fn reparent_tracing_span(&self) {
9497
// TODO: Move this duplicate logic into its own impl
9598
let state = self.state.read().unwrap();
9699
if state.active_spans.is_empty() {
@@ -110,5 +113,4 @@ impl ObserveContext {
110113
}
111114
}
112115

113-
// TODO(Caleb): Reorder things
114116
// TODO(Caleb): Make otel a workspace dependency

crates/factor-outbound-http/src/spin.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ impl spin_http::Host for crate::InstanceState {
1313
fields(otel.kind = "client", url.full = Empty, http.request.method = Empty,
1414
http.response.status_code = Empty, otel.name = Empty, server.address = Empty, server.port = Empty))]
1515
async fn send_request(&mut self, req: Request) -> Result<Response, HttpError> {
16-
self.observe_context
17-
.reparent_tracing_span_this_was_lanns_idea();
16+
self.observe_context.reparent_tracing_span();
1817

1918
let span = Span::current();
2019
record_request_fields(&span, &req);

crates/factor-outbound-http/src/wasi.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,7 @@ impl<'a> WasiHttpView for WasiHttpImplInner<'a> {
8686
mut request: Request<wasmtime_wasi_http::body::HyperOutgoingBody>,
8787
mut config: wasmtime_wasi_http::types::OutgoingRequestConfig,
8888
) -> wasmtime_wasi_http::HttpResult<wasmtime_wasi_http::types::HostFutureIncomingResponse> {
89-
self.state
90-
.observe_context
91-
.reparent_tracing_span_this_was_lanns_idea();
89+
self.state.observe_context.reparent_tracing_span();
9290

9391
// wasmtime-wasi-http fills in scheme and authority for relative URLs
9492
// (e.g. https://:443/<path>), which makes them hard to reason about.

crates/trigger-http/src/wasi.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ impl HttpExecutor for WasiHttpExecutor {
9999
};
100100

101101
// TODO(Caleb): Verify that using tracing::Span::current() does not cause regressions
102+
// TODO(Caleb): Do we even need the second instrument?
102103
let handle = task::spawn(
103104
async move {
104105
let result = match handler {

wit/deps/observe/traces.wit

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ interface traces {
2020
/// If one of the keys already exists for an attribute of the Span it will be overwritten with the corresponding new value.
2121
set-attributes: func(attributes: list<key-value>);
2222

23-
// TODO: Get span context?
23+
/// Get the `span-context` for this `span`.
24+
// span-context: func() -> span-context;
2425

2526
// TODO: Is recording?
2627

@@ -69,7 +70,7 @@ interface traces {
6970
s64-array(list<s64>),
7071
}
7172

72-
/// Identifying trace information about a span.
73+
/// Identifying trace information about a span that can be serialized and propagated.
7374
// TODO: Make types for the trace-id's and such?
7475
record span-context {
7576
/// Hexidecimal representation of the trace id.

0 commit comments

Comments
 (0)