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

parse only comma-less field part as field #2936

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions tracing-subscriber/src/filter/env/directive.rs
Expand Up @@ -192,8 +192,8 @@ impl Directive {
.name("fields")
.map(|c| {
FIELD_FILTER_RE
.find_iter(c.as_str())
.map(|c| field::Match::parse(c.as_str(), regex))
.captures_iter(c.as_str())
.map(|c| field::Match::parse(c.get(1).unwrap().as_str(), regex))
.collect::<Result<Vec<_>, _>>()
})
.unwrap_or_else(|| Ok(Vec::new()));
Expand Down
16 changes: 15 additions & 1 deletion tracing-subscriber/src/filter/env/mod.rs
Expand Up @@ -924,7 +924,7 @@ mod tests {

#[test]
fn callsite_enabled_includes_span_directive_multiple_fields() {
let filter = EnvFilter::new("app[mySpan{field=\"value\",field2=2}]=debug")
let filter = EnvFilter::try_new("app[mySpan{field=\"value\",field2=2}]=debug").unwrap()
.with_collector(NoCollector);
static META: &Metadata<'static> = &Metadata::new(
"mySpan",
Expand All @@ -939,6 +939,20 @@ mod tests {

let interest = filter.register_callsite(META);
assert!(interest.is_never());

static META2: &Metadata<'static> = &Metadata::new(
"mySpan",
"app",
Level::TRACE,
None,
None,
None,
FieldSet::new(&["field", "field2"], identify_callsite!(&Cs)),
Kind::SPAN,
);

let interest = filter.register_callsite(META);
assert!(interest.is_always());
}

#[test]
Expand Down