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
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions tracing-subscriber/src/filter/directive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ pub struct ParseError {
#[derive(Debug, PartialEq, Eq, Clone)]
pub(crate) struct StaticDirective {
pub(in crate::filter) target: Option<String>,
pub(in crate::filter) field_names: Vec<String>,
span: Option<String>,
field_names: Vec<String>,
pub(in crate::filter) level: LevelFilter,
}

Expand Down Expand Up @@ -162,11 +163,13 @@ impl DirectiveSet<StaticDirective> {
impl StaticDirective {
pub(in crate::filter) fn new(
target: Option<String>,
span: Option<String>,
field_names: Vec<String>,
level: LevelFilter,
) -> Self {
Self {
target,
span,
field_names,
level,
}
Expand Down Expand Up @@ -249,6 +252,14 @@ impl Match for StaticDirective {
}
}

// Do we have a name filter, and does it match the metadata's name?
// TODO(eliza): put name globbing here?
if let Some(ref name) = self.span {
if name != meta.name() {
return false;
}
}

if meta.is_event() && !self.field_names.is_empty() {
let fields = meta.fields();
for name in &self.field_names {
Expand All @@ -270,6 +281,7 @@ impl Default for StaticDirective {
fn default() -> Self {
StaticDirective {
target: None,
span: None,
field_names: Vec::new(),
level: LevelFilter::ERROR,
}
Expand Down Expand Up @@ -361,9 +373,10 @@ impl FromStr for StaticDirective {
};
let level = part1.parse()?;
return Ok(Self {
level,
field_names,
target,
span: None,
field_names,
level,
});
}

Expand All @@ -373,14 +386,16 @@ impl FromStr for StaticDirective {
// * `info`
Ok(match part0.parse::<LevelFilter>() {
Ok(level) => Self {
level,
target: None,
span: None,
field_names: Vec::new(),
level,
},
Err(_) => Self {
target: Some(String::from(part0)),
level: LevelFilter::TRACE,
span: None,
field_names: Vec::new(),
level: LevelFilter::TRACE,
},
})
}
Expand Down
Loading