Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow extra fields for span created by the #[instrument] macro #573

Closed
jeromegn opened this issue Feb 6, 2020 · 0 comments · Fixed by #596
Closed

Allow extra fields for span created by the #[instrument] macro #573

jeromegn opened this issue Feb 6, 2020 · 0 comments · Fixed by #596
Labels
crate/attributes Related to the `tracing-attributes` crate good first issue Good for newcomers kind/feature New feature or request

Comments

@jeromegn
Copy link
Contributor

jeromegn commented Feb 6, 2020

Feature Request

Crates

  • tracing-attributes

Motivation

This is to be able to record a value later on like Span::current().record("field", value) within the function.

Proposal

I'm not entirely sure since I haven't worked with attribute macros much before.

#[instrument(fields(key = "value"))]

or even

#[instrument(fields(foo, hello = "world"))]

allowing empty fields if #548 is merged.

Alternatives

Open to alternatives, but I couldn't think of one!

@hawkw hawkw added crate/attributes Related to the `tracing-attributes` crate kind/feature New feature or request good first issue Good for newcomers labels Feb 6, 2020
hawkw pushed a commit that referenced this issue Feb 24, 2020
…596)

This PR adds support for adding arbitrary key/value pairs to be used as
fields to `tracing::instrument`.

Current syntax:
```rust
#[instrument(fields(key = "value", v = 1, b = true, empty))]
```

- Empty keys are supported
- If a key is not a single identifier, it's value is not a
  string/int/bool (or missing), is repeated or shares a name with a
  parameter, an error is reported

Fixes: #573
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crate/attributes Related to the `tracing-attributes` crate good first issue Good for newcomers kind/feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants