-
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
[routingprocessor] Make exporters registration more generic. #13529
[routingprocessor] Make exporters registration more generic. #13529
Conversation
b629885
to
712240e
Compare
cc: @gouthamve |
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 like this a lot! I would like better documentation on the type parameters, stating what they are expected to be, but other than that, it looks very good!
If this is the first usage of generics on this code base, we might want to let other maintainers know.
logger: logger, | ||
router: newRouter(*oCfg, logger), | ||
logger: logger, | ||
metricsRouter: newRouter[component.MetricsExporter](*oCfg, logger), |
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 might be the first usage of generics in this code base. Are you able to find other uses? If this is the first, we might want to give a heads up to other maintainers.
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 couldn't find any other usage of generics in contrib repository. Is there an easy way to give heads up to maintainers?
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.
@open-telemetry/collector-contrib-maintainer , heads up: we are about to introduce the first usage of generics in the code base. Does anyone have anything against this?
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.
The TQL already has some due to the participle package requiring them. It is about to have some more via #13320.
@@ -344,7 +340,7 @@ func (r *router[E]) registerExporters(exporters map[config.ComponentID]component | |||
for id, exp := range exporters { | |||
exporter, ok := exp.(E) | |||
if !ok { | |||
return fmt.Errorf("the exporter %q isn't a ... exporter", id.String()) | |||
return fmt.Errorf("the exporter %q isn't a %T exporter", id.String(), new(E)) |
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.
Sweet! What does it yield?
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 will print smth like the exporter "otlp" isn't a *component.TracesExporter exporter
1d3f848
to
b1e9942
Compare
b1e9942
to
7a5710e
Compare
@@ -34,69 +34,71 @@ import ( | |||
// structure (plog.Logs, pmetric.Metrics and ptrace.Traces respectively) in order | |||
// to not cause higher CPU usage in the exporters when exproting data (it's always | |||
// better to batch before exporting). | |||
type router struct { | |||
type router[E component.Exporter] struct { |
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 wanted to introduce a type constraint for exporters to limit type params only to component.TracesExporter
,
component.MetricsExporter
, and component.LogsExporter
but it seems that currently it is not possible to union types with behavioural interfaces.
Looks good. I don't think we need a changelog entry for this, as there should not be any behavior change. I'll label this accordingly if that's your understanding as well. |
Yes, we do not change the semantic here, so it is fine to skip the change log entry. |
Description:
Make exporters registration more generic. It should simplify using tql in routing table PoC for #13158
Link to tracking Issue:
Testing:
Documentation: