Skip to content

Commit f7cb8ae

Browse files
authored
Merge pull request #2348 from calebschoepp/observability-start
feat(*): Implement the skeleton of an OTEL observability system
2 parents 4c4fd26 + 47a2658 commit f7cb8ae

File tree

24 files changed

+1125
-86
lines changed

24 files changed

+1125
-86
lines changed

Cargo.lock

Lines changed: 215 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ spin-locked-app = { path = "crates/locked-app" }
6161
spin-manifest = { path = "crates/manifest" }
6262
spin-oci = { path = "crates/oci" }
6363
spin-plugins = { path = "crates/plugins" }
64+
spin-telemetry = { path = "crates/telemetry" }
6465
spin-templates = { path = "crates/templates" }
6566
spin-trigger = { path = "crates/trigger" }
6667
spin-trigger-http = { path = "crates/trigger-http" }

crates/core/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ cap-std = "2.0.0"
1818
cap-primitives = "2.0.0"
1919
tokio = "1.0"
2020
bytes = "1.0"
21+
spin-telemetry = { path = "../telemetry" }
2122

2223
[target.'cfg(unix)'.dependencies]
2324
rustix = "0.37.19"

crates/core/src/lib.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,17 @@ impl<T: Send + OutboundWasiHttpHandler> WasiHttpView for Data<T> {
195195
&mut self.table
196196
}
197197

198+
#[instrument(name = "start_outbound_http_request", skip_all, fields(otel.kind = "client"))]
198199
fn send_request(
199200
&mut self,
200-
request: wasmtime_wasi_http::types::OutgoingRequest,
201+
mut request: wasmtime_wasi_http::types::OutgoingRequest,
201202
) -> wasmtime::Result<
202203
wasmtime::component::Resource<wasmtime_wasi_http::types::HostFutureIncomingResponse>,
203204
>
204205
where
205206
Self: Sized,
206207
{
208+
spin_telemetry::inject_trace_context(&mut request.request);
207209
T::send_request(self, request)
208210
}
209211
}
@@ -393,14 +395,14 @@ impl<T: OutboundWasiHttpHandler + Send + Sync> Engine<T> {
393395
}
394396

395397
/// Creates a new [`InstancePre`] for the given [`Component`].
396-
#[instrument(skip_all)]
398+
#[instrument(skip_all, level = "debug")]
397399
pub fn instantiate_pre(&self, component: &Component) -> Result<InstancePre<T>> {
398400
let inner = self.linker.instantiate_pre(component)?;
399401
Ok(InstancePre { inner })
400402
}
401403

402404
/// Creates a new [`ModuleInstancePre`] for the given [`Module`].
403-
#[instrument(skip_all)]
405+
#[instrument(skip_all, level = "debug")]
404406
pub fn module_instantiate_pre(&self, module: &Module) -> Result<ModuleInstancePre<T>> {
405407
let inner = self.module_linker.instantiate_pre(module)?;
406408
Ok(ModuleInstancePre { inner })
@@ -429,7 +431,7 @@ pub struct InstancePre<T> {
429431

430432
impl<T: Send + Sync> InstancePre<T> {
431433
/// Instantiates this instance with the given [`Store`].
432-
#[instrument(skip_all)]
434+
#[instrument(skip_all, level = "debug")]
433435
pub async fn instantiate_async(&self, store: &mut Store<T>) -> Result<Instance> {
434436
self.inner.instantiate_async(store).await
435437
}
@@ -458,7 +460,7 @@ pub struct ModuleInstancePre<T> {
458460

459461
impl<T: Send + Sync> ModuleInstancePre<T> {
460462
/// Instantiates this instance with the given [`Store`].
461-
#[instrument(skip_all)]
463+
#[instrument(skip_all, level = "debug")]
462464
pub async fn instantiate_async(&self, store: &mut Store<T>) -> Result<ModuleInstance> {
463465
self.inner.instantiate_async(store).await
464466
}

0 commit comments

Comments
 (0)