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

[routingprocessor] Make exporters registration more generic. #13529

Merged
merged 3 commits into from
Aug 24, 2022

Conversation

kovrus
Copy link
Member

@kovrus kovrus commented Aug 23, 2022

Description:

Make exporters registration more generic. It should simplify using tql in routing table PoC for #13158

Link to tracking Issue:

Testing:

Documentation:

@kovrus kovrus force-pushed the issue-13158-refactoring branch from b629885 to 712240e Compare August 23, 2022 11:55
@kovrus kovrus marked this pull request as ready for review August 23, 2022 12:26
@kovrus kovrus requested a review from a team August 23, 2022 12:26
@kovrus kovrus requested a review from jpkrohling as a code owner August 23, 2022 12:26
@kovrus
Copy link
Member Author

kovrus commented Aug 23, 2022

cc: @gouthamve

Copy link
Member

@jpkrohling jpkrohling left a 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),
Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member

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?

Copy link
Member

@TylerHelmuth TylerHelmuth Aug 23, 2022

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.

processor/routingprocessor/router.go Outdated Show resolved Hide resolved
processor/routingprocessor/router.go Outdated Show resolved Hide resolved
processor/routingprocessor/router.go Outdated Show resolved Hide resolved
processor/routingprocessor/router.go Outdated Show resolved Hide resolved
processor/routingprocessor/router.go Outdated Show resolved Hide resolved
@@ -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))
Copy link
Member

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?

Copy link
Member Author

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

@kovrus kovrus force-pushed the issue-13158-refactoring branch from 1d3f848 to b1e9942 Compare August 24, 2022 07:28
@kovrus kovrus force-pushed the issue-13158-refactoring branch from b1e9942 to 7a5710e Compare August 24, 2022 07:30
@@ -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 {
Copy link
Member Author

@kovrus kovrus Aug 24, 2022

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.

@jpkrohling
Copy link
Member

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.

@kovrus
Copy link
Member Author

kovrus commented Aug 24, 2022

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.

@jpkrohling jpkrohling added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Aug 24, 2022
@jpkrohling jpkrohling merged commit 1fc794d into open-telemetry:main Aug 24, 2022
@kovrus kovrus deleted the issue-13158-refactoring branch August 24, 2022 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Skip Changelog PRs that do not require a CHANGELOG.md entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants