Skip to content

Commit

Permalink
tracing-subscriber: fix and extend env filter test with multiple fields
Browse files Browse the repository at this point in the history
  • Loading branch information
mladedav committed Apr 30, 2024
1 parent 3dbf379 commit 8a1f020
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion tracing-subscriber/src/filter/env/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,38 @@ mod tests {
);

let interest = filter.register_callsite(META);
assert!(interest.is_never());
// The span does not match but as long as we have a dynamic filter, we always say at least `sometimes`.
assert!(interest.is_sometimes());

static META_MATCH: &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_MATCH);
// This span matches the filter.
assert!(interest.is_always());

static META_BAD: &Metadata<'static> = &Metadata::new(
"differentSpan",
"definitelyNotApp",
Level::TRACE,
None,
None,
None,
FieldSet::new(&[], identify_callsite!(&Cs)),
Kind::SPAN,
);

let interest = filter.register_callsite(META_BAD);
// The collector is not interested in unrelated spans.
assert!(interest.is_sometimes());
}

#[test]
Expand Down

0 comments on commit 8a1f020

Please sign in to comment.