-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[pkg/telemetryquerylanguage] add replace_key_all_patterns function #12991
[pkg/telemetryquerylanguage] add replace_key_all_patterns function #12991
Conversation
@fatsheep9146 can you break this into 2 PR, one for the function add and one to the transform processor? It'd be nice to do it all in one PR but any functions added to transformprocessor should have integration tests added to a signals processor_test.go and I think the PR would be too large. |
I've removed it from transform processor, and I will submit second PR until this one is merged. |
e683574
to
ee91201
Compare
The integration test seems unrelated to this pr @TylerHelmuth |
@bogdandrutu @kentquirk curious on your thoughts on this function. It will certainly meet the needs of the user to rename keys in bulk, but we'd end up with For this particular use case we could instead update |
@fatsheep9146 please update your implementation to match this comment instead of adding a new function. |
833423a
to
060243e
Compare
I already add a new parameter, please help review this =D @TylerHelmuth |
pkg/telemetryquerylanguage/functions/tqlotel/func_replace_all_patterns.go
Outdated
Show resolved
Hide resolved
060243e
to
279181d
Compare
Please help review this again =D @TylerHelmuth |
pkg/telemetryquerylanguage/functions/tqlotel/func_replace_all_patterns.go
Outdated
Show resolved
Hide resolved
pkg/telemetryquerylanguage/functions/tqlotel/func_replace_all_patterns.go
Outdated
Show resolved
Hide resolved
pkg/telemetryquerylanguage/functions/tqlotel/func_replace_all_patterns.go
Outdated
Show resolved
Hide resolved
All comments are fixed. @TylerHelmuth |
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.
Thanks for doing this!
0b586fd
to
3f59475
Compare
@bogdandrutu Could you help review this? |
3f59475
to
34bc53b
Compare
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.
This seems correct as is, but I wonder if it's worth trying to avoid some allocations in the general case.
stringVal := value.StringVal() | ||
if compiledPattern.MatchString(stringVal) { | ||
value.SetStringVal(compiledPattern.ReplaceAllLiteralString(stringVal, replacement)) | ||
updated.EnsureCapacity(attrs.Len()) |
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 think it will be a fairly common occurrence that this function does no useful work -- that none of the attributes match the given pattern. Consequently, it might make sense, then, to do one of two things:
- set a flag when the match succeeds, and only do the
target.Set
if it has succeeded at least once; this avoids rewriting target, although it doesn't avoid the allocation - do a pre-pass over the keys looking for a match, and if none is found exit without allocating the
updated
value
Is it worth it?
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.
We haven't done serious benchmarks for OTTl or the transform processor yet, but we should. As both mature I say we should take performance improvements wherever we can find them.
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.
Although I think the suggestion can be done in a future PR if you open an issue to call it out.
I think I'd also like to merge all the Replace functions into one.
@fatsheep9146 please address conflicts |
34bc53b
to
9b47d83
Compare
I think the failed task is due to transformprocessor
Should I fix those in seperate prs? @TylerHelmuth |
@fatsheep9146 Ya those errors don't seem correct. Attempt to fix in another PR, but I suspect if you create a new branch from main you won't see them. |
Sorry, it's my mistake, the reason is that in |
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.
Needs a rebase
9bc8594
to
19630cc
Compare
Rebase done, I think this is ready-to-merge. @codeboten @TylerHelmuth |
304a77d
to
c847139
Compare
@TylerHelmuth @codeboten Could you help add ready-to-merge label? |
Please add a changelog entry. |
10bc71a
to
c847139
Compare
@fatsheep9146 please rebase. |
Signed-off-by: Ziqi Zhao <[email protected]>
Signed-off-by: Ziqi Zhao <[email protected]>
Co-authored-by: Tyler Helmuth <[email protected]>
61a132e
to
d50ea13
Compare
Signed-off-by: Ziqi Zhao <[email protected]>
This is awesome, thanks so much everyone 🍾 |
…pen-telemetry#12991) * [pkg/telemetryquerylanguage] enhance replace_all_patterns function
Signed-off-by: Ziqi Zhao [email protected]
Description:
fix #12631