Skip to content

promote tags.* span fields to tags on error events #1083

@untitaker

Description

@untitaker
#[instrument(fields(tags.host = %account.host))]
async fn sync(account: Account) {
    tracing::error!("account sync failed");
}

This code, when called, produces a span with a host tag, and an error without one. I would like the host tag to apply to the error too.

I.e. instrument(fields()) should be equivalent to sentry::set_tag, rather than current_span.set_tag.

The main reason is that I find it irritating to have instrumentation apply to all of my spans, but not on the errors, where it's most important.

My current workaround is to add tags to the error explicitly:

#[instrument(fields(tags.host = %account.host))]
async fn sync(account: Account) {
    tracing::error!("account sync failed", tags.host = %account.host);
}

Solution Brainstorm

Internally, I'm not sure if that means a new scope needs to be pushed for each span, or something like that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    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