Skip to content

Unable to set parent context when using #[instrument] macro #253

@nnmm

Description

@nnmm

Bug Report

Version

v0.32.1

Platform

Linux x86_64

Description

tracing::Span::current().set_parent(parent_cx) could in the past be used for the receiving end of OTEL trace context propagation, but since 0.32 (specifically c4fe96a) it doesn't work anymore on entered spans.

If I'm not mistaken, that means there is no way to set the parent of a #[instrument] span, because these spans are entered automatically. #[instrument] has a parent argument, but that expects a tracing::Span, not an opentelemetry::Context, so I don't think fits the bill.

#[instrument] is by far the most ergonomic way to create spans for async functions, and it would be very limiting in my opinion to not be able to propagate trace context to these spans.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions