spin
spin copied to clipboard
[OTel]: Spans produced by `spin_sdk::key_value::Store::set` don't have a parent assigned
Spans produced as part of using the key-value store set
function, don't have a parent assigned. This results in having two independent traces from a single HTTP API invocation
I've tested other actions in the context of key-value store (such as exists
and `get) which are all represented correctly:
Versions
-
spin
CLI:spin 2.5.1 (cba6773 2024-05-14)
-
spin-sdk
crate:3.0.1
Repro
See the following pseudo code for reproducing the behavior:
use spin_sdk::http::{IntoResponse, Request, Response};
use spin_sdk::http_component;
use spin_sdk::key_value::Store;
/// A simple Spin HTTP component.
#[http_component]
fn handle_api(req: Request) -> anyhow::Result<impl IntoResponse> {
println!("Handling request to {:?}", req.header("spin-full-url"));
let store = Store::open_default()?;
let exists = store.exists("foo")?;
if !exists {
return Ok(Response::new(404, ()));
}
let Some(value) = store.get("foo")? else {
return Ok(Response::new(204, ()));
};
store.set("bar", b"baz")?;
Ok(Response::builder()
.status(200)
.header("content-type", "text/plain")
.body(value)
.build())
}