Skip to content

Commit

Permalink
Remove tracing error span in hot path (vectordotdev#8579)
Browse files Browse the repository at this point in the history
This commit removes a `span!` call with `Level::ERROR` setting from
`FunctionCall::resolve`. My understanding here is that this span did not
terminate into any collector and will not impact user observable remap
behavior. This does, however, add +9Mb/s throughput to the configuration
described in vectordotdev#8512.

Signed-off-by: Brian L. Troutwine <brian@troutwine.us>
Signed-off-by: dbcfd <bdbrowning2@gmail.com>
  • Loading branch information
blt authored and dbcfd committed Aug 18, 2021
1 parent 25f7b8f commit 7786a8c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 26 deletions.
4 changes: 2 additions & 2 deletions lib/shared/src/datetime.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use chrono::{DateTime, Local, ParseError, TimeZone as _, Utc};
use chrono_tz::Tz;
use derivative::Derivative;
use std::fmt::{self, Debug};
use std::fmt::Debug;

#[derive(Clone, Copy, Debug, Derivative, Eq, PartialEq)]
#[derivative(Default)]
Expand Down Expand Up @@ -58,7 +58,7 @@ pub mod ser_de {
impl<'de> de::Visitor<'de> for TimeZoneVisitor {
type Value = TimeZone;

fn expecting(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "a time zone name")
}

Expand Down
2 changes: 1 addition & 1 deletion lib/vrl/compiler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ publish = false
[dependencies]
diagnostic = { package = "vrl-diagnostic", path = "../diagnostic" }
parser = { package = "vrl-parser", path = "../parser" }
shared = { path = "../../shared", default-features = false }
shared = { path = "../../shared", default-features = false, features = ["conversion"] }
lookup = { path = "../../lookup" }

bitflags = "1"
Expand Down
43 changes: 20 additions & 23 deletions lib/vrl/compiler/src/expression/function_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use crate::parser::{Ident, Node};
use crate::{value::Kind, Context, Expression, Function, Resolved, Span, State, TypeDef};
use diagnostic::{DiagnosticError, Label, Note, Urls};
use std::fmt;
use tracing::{span, Level};

#[derive(Clone)]
pub struct FunctionCall {
Expand Down Expand Up @@ -204,31 +203,29 @@ impl FunctionCall {

impl Expression for FunctionCall {
fn resolve(&self, ctx: &mut Context) -> Resolved {
span!(Level::ERROR, "remap", vrl_position = &self.span.start()).in_scope(|| {
self.expr.resolve(ctx).map_err(|err| match err {
ExpressionError::Abort { .. } => {
panic!("abort errors must only be defined by `abort` statement")
}
self.expr.resolve(ctx).map_err(|err| match err {
ExpressionError::Abort { .. } => {
panic!("abort errors must only be defined by `abort` statement")
}
ExpressionError::Error {
message,
mut labels,
notes,
} => {
labels.push(Label::primary(message.clone(), self.span));

ExpressionError::Error {
message,
mut labels,
message: format!(
r#"function call error for "{}" at ({}:{}): {}"#,
self.ident,
self.span.start(),
self.span.end(),
message
),
labels,
notes,
} => {
labels.push(Label::primary(message.clone(), self.span));

ExpressionError::Error {
message: format!(
r#"function call error for "{}" at ({}:{}): {}"#,
self.ident,
self.span.start(),
self.span.end(),
message
),
labels,
notes,
}
}
})
}
})
}

Expand Down

0 comments on commit 7786a8c

Please sign in to comment.