Skip to content

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

Closed
@hawkw

Description

@hawkw

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    crate/tracingRelated to the `tracing` cratekind/featureNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions