spin icon indicating copy to clipboard operation
spin copied to clipboard

[OTel]: Spans produced by `spin_sdk::key_value::Store::set` don't have a parent assigned

Open ThorstenHans opened this issue 3 months ago • 11 comments

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

image

I've tested other actions in the context of key-value store (such as exists and `get) which are all represented correctly:

image

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

ThorstenHans avatar May 22 '24 22:05 ThorstenHans