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

tracing: Add span- and event-specific enabled! variants #1892

Closed
hawkw opened this issue Feb 3, 2022 · 1 comment · Fixed by #1900
Closed

tracing: Add span- and event-specific enabled! variants #1892

hawkw opened this issue Feb 3, 2022 · 1 comment · Fixed by #1900
Labels
crate/tracing Related to the `tracing` crate kind/feature New feature or request

Comments

@hawkw
Copy link
Member

hawkw commented Feb 3, 2022

Feature Request

Crates

  • tracing

Motivation

Currently, the callsites constructed by the enabled! macro count as neither spans nor events, so that they are not effected by filtering configurations that specifically enable spans or specifically enable events. This reduces false positives. In some situations, though, a user may wish to check specifically if a span would be enabled, or if an event would be enabled. See #1821 (comment) for details.

Proposal

PR #1891 makes a change in tracing-core to allow constructing callsite kinds that are spans/events and hints at the same time. This can be used to add support for checking if specific kinds of callsite would be enabled.

We should add new span_enabled! and event_enabled! macros that use this API. These macros would behave like enabled! but would create SPAN | HINT and EVENT | HINT callsites, respectively.

Alternatives

Alternatively, we could add this to the existing enabled! macro, like enabled!(span, ...) and enabled!(event, ...). IMO, just making separate macros is a bit more obvious from a UX perspective, but I'm open to being convinced otherwise.

@hawkw hawkw added kind/feature New feature or request crate/tracing Related to the `tracing` crate labels Feb 3, 2022
@hawkw
Copy link
Member Author

hawkw commented Feb 3, 2022

cc @guswynn

hawkw added a commit that referenced this issue Mar 31, 2022
## Motivation

Closes #1892

## Solution

This branch adds new `span_enabled!` and `event_enabled!` macros.

I went withe sharing as much of the macro as possible. The new macros
were implemented by adding a `kind:` parameter to `enabled!`, and invoking
`enabled!` with the appropriate `kind:` argument. This means in the
docs, the macro only shows the `($($rest:tt)*)=> (...)` variant, but I
think linking to the `enabled!` docs should be fine. Also, I find the
macro pattern part of rustdoc to be very hard to understand, and I think
many people dont look at it.

Co-authored-by: Eliza Weisman <eliza@buoyant.io>
hawkw added a commit that referenced this issue Apr 1, 2022
## Motivation

Closes #1892

## Solution

This branch adds new `span_enabled!` and `event_enabled!` macros.

I went withe sharing as much of the macro as possible. The new macros
were implemented by adding a `kind:` parameter to `enabled!`, and invoking
`enabled!` with the appropriate `kind:` argument. This means in the
docs, the macro only shows the `($($rest:tt)*)=> (...)` variant, but I
think linking to the `enabled!` docs should be fine. Also, I find the
macro pattern part of rustdoc to be very hard to understand, and I think
many people dont look at it.

Co-authored-by: Eliza Weisman <eliza@buoyant.io>
hawkw added a commit that referenced this issue Apr 1, 2022
## Motivation

Closes #1892

## Solution

This branch adds new `span_enabled!` and `event_enabled!` macros.

I went withe sharing as much of the macro as possible. The new macros
were implemented by adding a `kind:` parameter to `enabled!`, and invoking
`enabled!` with the appropriate `kind:` argument. This means in the
docs, the macro only shows the `($($rest:tt)*)=> (...)` variant, but I
think linking to the `enabled!` docs should be fine. Also, I find the
macro pattern part of rustdoc to be very hard to understand, and I think
many people dont look at it.

Co-authored-by: Eliza Weisman <eliza@buoyant.io>
hawkw added a commit that referenced this issue Apr 1, 2022
## Motivation

Closes #1892

## Solution

This branch adds new `span_enabled!` and `event_enabled!` macros.

I went withe sharing as much of the macro as possible. The new macros
were implemented by adding a `kind:` parameter to `enabled!`, and invoking
`enabled!` with the appropriate `kind:` argument. This means in the
docs, the macro only shows the `($($rest:tt)*)=> (...)` variant, but I
think linking to the `enabled!` docs should be fine. Also, I find the
macro pattern part of rustdoc to be very hard to understand, and I think
many people dont look at it.

Co-authored-by: Eliza Weisman <eliza@buoyant.io>
hawkw added a commit that referenced this issue Apr 1, 2022
## Motivation

Closes #1892

## Solution

This branch adds new `span_enabled!` and `event_enabled!` macros.

I went withe sharing as much of the macro as possible. The new macros
were implemented by adding a `kind:` parameter to `enabled!`, and invoking
`enabled!` with the appropriate `kind:` argument. This means in the
docs, the macro only shows the `($($rest:tt)*)=> (...)` variant, but I
think linking to the `enabled!` docs should be fine. Also, I find the
macro pattern part of rustdoc to be very hard to understand, and I think
many people dont look at it.

Co-authored-by: Eliza Weisman <eliza@buoyant.io>
hawkw added a commit that referenced this issue Apr 1, 2022
## Motivation

Closes #1892

## Solution

This branch adds new `span_enabled!` and `event_enabled!` macros.

I went withe sharing as much of the macro as possible. The new macros
were implemented by adding a `kind:` parameter to `enabled!`, and invoking
`enabled!` with the appropriate `kind:` argument. This means in the
docs, the macro only shows the `($($rest:tt)*)=> (...)` variant, but I
think linking to the `enabled!` docs should be fine. Also, I find the
macro pattern part of rustdoc to be very hard to understand, and I think
many people dont look at it.

Co-authored-by: Eliza Weisman <eliza@buoyant.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crate/tracing Related to the `tracing` crate kind/feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant