-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[processor/transform] Allow specifying functions per context #16251
Conversation
} | ||
} | ||
|
||
func Functions() map[string]interface{} { |
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 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
.
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 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. |
…lemetry#16251) * Allow specifying functions per context
…lemetry#16251) * Allow specifying functions per context
Description:
While working on a
drop
function I ran into an unrelated bug where the metric ContextStatements were using functions initialized withottldatapoint.TransformContext
. This PR fixes the bug by forcingParserCollection
to use theWithOption
pattern to set context parsers with their specific set of functions.Testing:
Unit tests