Skip to content

Async calls and nested span events #1530

Closed Answered by lalitb
ramgdev asked this question in Q&A
Discussion options

You must be logged in to vote

@ramgdev Thanks for sharing the sample code. Looking into the example, the output is as expected. If we look into the function_b, which is called asynchronously from function_a with an explicit context context_a:

pub async fn function_b() -> Result<()> {
    println!("function_b called");
    let tracer = global::tracer("mytracer");
    let parent_context = opentelemetry::Context::current();
    let mut span = tracer
        .span_builder("span_B".to_owned())
        .with_kind(SpanKind::Server)
        .start_with_context(&tracer, &parent_context);
    span.add_event("event_2".to_string(), vec![]);
    let context_b = opentelemetry::Context::default().with_span(span);
    match opentelem…

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
5 replies
@ramgdev
Comment options

@lalitb
Comment options

@ramgdev
Comment options

@lalitb
Comment options

Answer selected by ramgdev
@ramgdev
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants