Skip to content

Commit

Permalink
Merge pull request #2348 from calebschoepp/observability-start
Browse files Browse the repository at this point in the history
feat(*): Implement the skeleton of an OTEL observability system
  • Loading branch information
calebschoepp authored Mar 22, 2024
2 parents 4c4fd26 + 47a2658 commit f7cb8ae
Show file tree
Hide file tree
Showing 24 changed files with 1,125 additions and 86 deletions.
215 changes: 215 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ spin-locked-app = { path = "crates/locked-app" }
spin-manifest = { path = "crates/manifest" }
spin-oci = { path = "crates/oci" }
spin-plugins = { path = "crates/plugins" }
spin-telemetry = { path = "crates/telemetry" }
spin-templates = { path = "crates/templates" }
spin-trigger = { path = "crates/trigger" }
spin-trigger-http = { path = "crates/trigger-http" }
Expand Down
1 change: 1 addition & 0 deletions crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ cap-std = "2.0.0"
cap-primitives = "2.0.0"
tokio = "1.0"
bytes = "1.0"
spin-telemetry = { path = "../telemetry" }

[target.'cfg(unix)'.dependencies]
rustix = "0.37.19"
Expand Down
12 changes: 7 additions & 5 deletions crates/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,17 @@ impl<T: Send + OutboundWasiHttpHandler> WasiHttpView for Data<T> {
&mut self.table
}

#[instrument(name = "start_outbound_http_request", skip_all, fields(otel.kind = "client"))]
fn send_request(
&mut self,
request: wasmtime_wasi_http::types::OutgoingRequest,
mut request: wasmtime_wasi_http::types::OutgoingRequest,
) -> wasmtime::Result<
wasmtime::component::Resource<wasmtime_wasi_http::types::HostFutureIncomingResponse>,
>
where
Self: Sized,
{
spin_telemetry::inject_trace_context(&mut request.request);
T::send_request(self, request)
}
}
Expand Down Expand Up @@ -393,14 +395,14 @@ impl<T: OutboundWasiHttpHandler + Send + Sync> Engine<T> {
}

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

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

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

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

0 comments on commit f7cb8ae

Please sign in to comment.