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

[pkg/telemetryquerylanguage] Add Join factory #13120

Merged
merged 1 commit into from
Aug 23, 2022

Conversation

evan-bradley
Copy link
Contributor

@evan-bradley evan-bradley commented Aug 9, 2022

Description:

This is a follow-up to #12706.

Add a Concat factory, which allows concatenating an arbitrary number of strings.

This function also converts types to a string representation, if easily applicable. Converting types like numbers or byte slices should relieve the user of having to think about which type something like an attribute is when concatenating it.

The exceptions to stringification are slices and maps, which may have large payloads. nil is stringified to allow the user flexibility and to make the resulting string more comprehensible; if they don't want to concatenate anything in these cases, a where-clause is possible.

Link to tracking Issue:

Fixes #12476

Testing:

Unit tests were added, manual tests were performed.

Documentation:

The tqlcommon package's README has been updated with documentation for the factory.

@TylerHelmuth
Copy link
Member

/cc @kentquirk

@evan-bradley evan-bradley force-pushed the issue-12476 branch 2 times, most recently from 5083b7f to 2f1e4b9 Compare August 10, 2022 14:24
Copy link
Member

@TylerHelmuth TylerHelmuth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@evan-bradley can you break this PR into 2 PRs, one where the function is added to pkg/telemetryquerylanguage and a second that adds the function to the transformprocessor? The PR that updates the transformprocessor should update one of the signal's processor_test.go with a new integration test for this function.

@evan-bradley evan-bradley force-pushed the issue-12476 branch 3 times, most recently from f09908a to eb9d296 Compare August 17, 2022 18:48
@evan-bradley evan-bradley changed the title [pkg/telemetryquerylanguage] Add Concat factory [pkg/telemetryquerylanguage] Add Join factory Aug 17, 2022
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/telemetryquerylanguage/tql"
)

func Join(delimiter string, vals []tql.Getter) (tql.ExprFunc, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing I want to call out here is that this function could be either more efficient if we streamline the loop and Builder allocations to cut out some edge cases, or could be simpler if we are okay with allocating additional memory for a string list and letting the strings.Join function handle the joining. I took a middle-of-the-road approach since we're likely not going to be joining a substantial number of strings, but I also didn't want to be wasteful. I'm happy to consider alternate approaches if we want to optimize or simplify this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your implementation seems good to me.

"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/telemetryquerylanguage/tql"
)

func Join(delimiter string, vals []tql.Getter) (tql.ExprFunc, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your implementation seems good to me.

Copy link
Member

@kentquirk kentquirk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job on the test cases. Thanks.

@TylerHelmuth TylerHelmuth added the ready to merge Code review completed; ready to merge by maintainers label Aug 23, 2022
@djaglowski djaglowski merged commit 25be2e2 into open-telemetry:main Aug 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge Code review completed; ready to merge by maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[processor/transform] Add ability to concat strings
4 participants