getsentry / getsentry/sentry-rust

promote `tags.*` span fields to tags on error events

Open
#1,083 4 comments 2 reactions 0 assignees View on GitHub
Feature Rust Spans
Dominant language
Rust
Stars
752
Forks
190
Avg merge
1h 21m
Merged PRs (30d)
5

Description

```rust
#[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:

```rust
#[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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.