-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
feat(new transform): New remap
transform
#3341
Conversation
Nice work! @Jeffail if there was anything obviously wrong with the data model, could you open issues and add them to https://github.com/timberio/vector-product/issues/8? |
3eed634
to
b48d2b0
Compare
Where is the CI on this? 🤔 |
@@ -665,6 +673,90 @@ fn bench_elasticsearch_index(c: &mut Criterion) { | |||
); | |||
} | |||
|
|||
fn benchmark_remap(c: &mut Criterion) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
Running target/release/deps/bench-0f9a98460f4dba0d
add fields with remap time: [1.3603 us 1.3614 us 1.3625 us]
change: [-1.5879% +0.1667% +1.5785%] (p = 0.84 > 0.05)
No change in performance detected.
Found 1 outliers among 100 measurements (1.00%)
1 (1.00%) high mild
add fields with add_fields
time: [2.2038 us 2.2086 us 2.2152 us]
change: [-0.9292% -0.6531% -0.2980%] (p = 0.00 < 0.05)
Change within noise threshold.
Found 6 outliers among 100 measurements (6.00%)
1 (1.00%) low mild
2 (2.00%) high mild
3 (3.00%) high severe
Very nice. Good job. :)
use serde_json::json; | ||
|
||
#[test] | ||
fn check_path_query() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be useful to see whitespace including tests. Eg .foo\ bar\ baz
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Realised from this that I hadn't even implemented quoted path segments yet so good catch!
Signed-off-by: Ashley Jeffs <[email protected]>
Signed-off-by: Ashley Jeffs <[email protected]>
Signed-off-by: Ashley Jeffs <[email protected]>
Signed-off-by: Ashley Jeffs <[email protected]>
Signed-off-by: Ashley Jeffs <[email protected]>
Signed-off-by: Ashley Jeffs <[email protected]>
Signed-off-by: Ashley Jeffs <[email protected]>
Signed-off-by: Ashley Jeffs <[email protected]>
Signed-off-by: Ashley Jeffs <[email protected]>
Signed-off-by: Ashley Jeffs <[email protected]>
Signed-off-by: Ashley Jeffs <[email protected]>
Signed-off-by: Ashley Jeffs <[email protected]>
Signed-off-by: Ashley Jeffs <[email protected]>
Signed-off-by: Jean Mertz <[email protected]>
Signed-off-by: Jean Mertz <[email protected]>
Signed-off-by: Jean Mertz <[email protected]>
remap
transform
statement ~ | ||
NEWLINE* ~ "}" )? | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be worth putting NEWLINE*
on either side of the brackets so people can indent Allman style? Someone is inevitably going to try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some comments for cleanups you could consider, but they shouldn't change behavior or correctness.
let (left, right) = coerce_number_types(left?, right?); | ||
match left { | ||
Value::Float(fl) => match right { | ||
Value::Float(fr) => Value::Float(fl * fr), | ||
vr => { | ||
return Err(format!( | ||
"unable to multiply right-hand field type {:?}", | ||
vr | ||
)) | ||
} | ||
}, | ||
Value::Integer(il) => match right { | ||
Value::Integer(ir) => Value::Integer(il * ir), | ||
vr => { | ||
return Err(format!( | ||
"unable to multiply right-hand field type {:?}", | ||
vr | ||
)) | ||
} | ||
}, | ||
vl => return Err(format!("unable to multiply left-hand field type {:?}", vl)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the rest of the arms of this could use the match coerce_number_types(left?, right?)
treatment.
use string_cache::DefaultAtom as Atom; | ||
|
||
#[derive(Debug)] | ||
pub(in crate::mapping) struct Path { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's kind of annoying how much logic gets duplicated with https://github.com/timberio/vector/blob/master/src/event/util/log/path_iter.rs but I understand why
Co-authored-by: Bruce Guenter <[email protected]> Signed-off-by: Jean Mertz <[email protected]>
Co-authored-by: Bruce Guenter <[email protected]> Signed-off-by: Jean Mertz <[email protected]>
Co-authored-by: Bruce Guenter <[email protected]> Signed-off-by: Jean Mertz <[email protected]>
Co-authored-by: Bruce Guenter <[email protected]> Signed-off-by: Jean Mertz <[email protected]>
Co-authored-by: Bruce Guenter <[email protected]> Signed-off-by: Jean Mertz <[email protected]>
1601b2c
to
18acbbc
Compare
Signed-off-by: Jean Mertz <[email protected]>
Nice work 🎉 |
Co-authored-by: Bruce Guenter <[email protected]> Co-authored-by: Jean Mertz <[email protected]> Signed-off-by: Brian Menges <[email protected]>
Implements a new
remap
transform following https://github.com/timberio/vector/blob/master/rfcs/2020-07-21-2744-remapping-syntax.md, which provides a mapping language for expressing a series of translations for events:In order to mutate events with the existing API I've had to make a few value utility functions public, I'm hoping this is only temporary and that https://github.com/timberio/vector/blob/master/rfcs/2020-05-25-2692-more-usable-logevents.md will address some of the oddness of the API.
I've added TODO comments anywhere that uses event API's that are obsolete or just seem wrong to me, but in terms of functionality we seem to be okay for now, so no need to rush in those changes.
Path escaping is not currently implemented, my goal was to implement quoted segments like
.foo."bar.baz".buz
but I haven't dug into the event APIs enough to see if that's convenient. I'll take another look after arithmetic is added but from what I've seen thus far it looks like we're only able to use slash escapes like.foo.bar\.baz.buz
so I'll need to translate manually.Closes #3119
Closes #3467
Closes #3722
Closes https://github.com/timberio/vector-product/issues/70