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

[processor/transform] Allow specifying functions per context #16251

Merged
merged 7 commits into from
Nov 15, 2022

Conversation

TylerHelmuth
Copy link
Member

Description:
While working on a drop function I ran into an unrelated bug where the metric ContextStatements were using functions initialized with ottldatapoint.TransformContext. This PR fixes the bug by forcing ParserCollection to use the WithOption pattern to set context parsers with their specific set of functions.

Testing:
Unit tests

@TylerHelmuth TylerHelmuth requested a review from a team November 10, 2022 22:27
}
}

func Functions() map[string]interface{} {
Copy link
Member Author

Choose a reason for hiding this comment

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

This was the root of the issue: the metrics processor was calling this function to initialize the MetricsParserCollection, which was then using the registry to parse metric statements. The issue is that these functions are datapoint context functions, so when used with metric statements things would panic if a metric path was used that isn't in datapoints, such as name.

@github-actions github-actions bot added the processor/transform Transform processor label Nov 11, 2022
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.

I kept coming up with objections to the implementation details and then realizing that there was a good answer to each already. I'm now out of objections and I definitely like the idea here.

@TylerHelmuth
Copy link
Member Author

I kept coming up with objections to the implementation details and then realizing that there was a good answer to each already. I'm now out of objections and I definitely like the idea here.

@kentquirk I think a fair criticism of the Options approach here is that it implies that the ParserCollection could be created in a meaningful way with the LogParser or SpanParser etc when in reality that wouldn't really make sense.

I think it could be argued that it would be better to force passing in functions for the parsers that are getting initialized via parameters instead of option functions.

If this lived outside of the transformprocessor I think that would be the better solution to force proper usage. Otherwise you'd have to know to use options if you want those types of parsers.

@github-actions github-actions bot requested a review from kentquirk November 14, 2022 16:29
@TylerHelmuth TylerHelmuth added the ready to merge Code review completed; ready to merge by maintainers label Nov 14, 2022
@djaglowski djaglowski merged commit f031b3b into open-telemetry:main Nov 15, 2022
@TylerHelmuth TylerHelmuth deleted the tp-functions-per-context branch November 15, 2022 16:21
JaredTan95 pushed a commit to openinsight-proj/opentelemetry-collector-contrib that referenced this pull request Nov 21, 2022
shalper2 pushed a commit to shalper2/opentelemetry-collector-contrib that referenced this pull request Dec 6, 2022
@plantfansam plantfansam mentioned this pull request Jul 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
processor/transform Transform processor ready to merge Code review completed; ready to merge by maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants