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

Include span in static directive #3103

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pkoenig10
Copy link

@pkoenig10 pkoenig10 commented Oct 12, 2024

Motivation

Using EnvFilter with a directive that specifies a span name but does not specify any field values requires using dynamic directives even though all the information necessary to match the directive is known statically from the metadata. This incurs unnecessary runtime costs.

Solution

This PR adds a span field to StaticDirective. Directives with span names but no field values are now considered static directives.

This PR intentionally does not change the FromStr implementation or the capabilities afforded by Targets (which uses this FromStr implementation for StaticDirective). StaticDirective is simply an implementation detail that happens to be used by both EnvFilter and Targets. This is admittedly somewhat confusing. It might be better to split StaticDirective into separate types - one used by EnvFilter and another used by Targets.

This PR also makes a minor clarification/standardization by renaming the in_span field to span. This matches the nomenclature used in the directive syntax in the docs (ie. target[span{field=value}]=level). I've also reordered the initializer fields to consistently match the declaration order.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant