-
Notifications
You must be signed in to change notification settings - Fork 1.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
Make MakeFactoryMap generic and move to otelcol #12220
base: main
Are you sure you want to change the base?
Make MakeFactoryMap generic and move to otelcol #12220
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #12220 +/- ##
==========================================
+ Coverage 91.39% 91.45% +0.05%
==========================================
Files 468 469 +1
Lines 25591 25590 -1
==========================================
+ Hits 23390 23404 +14
+ Misses 1785 1775 -10
+ Partials 416 411 -5 ☔ View full report in Codecov by Sentry. |
Hm, CI says Edit: The issue was that I was using a different version of Go from the CI, so the |
This comment was marked as resolved.
This comment was marked as resolved.
I removed scraper from the test because the dependency changes were causing crosslink to add replaces where they weren't actually needed, might file an issue about that later. The generic code only relies on the |
@bogdandrutu will merge this on Friday, this seems fine to me but since otelcol is far from being stabilized we can iterate on the function if we need to @jade-guiton-dd can you solve the merge conflicts? |
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 pattern to avoid circular deps that I've seen is to move tests in a package "builder_test" in the same directory.
@@ -13,7 +13,7 @@ import ( | |||
|
|||
var ( | |||
errNilNextConsumer = errors.New("nil next Consumer") | |||
nopType = component.MustNewType("nop") | |||
NopType = component.MustNewType("nop") |
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.
Why this change?
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 moved the tests into the separate builderstest
package to avoid circular dependencies, and this variable is used in the tests, so I needed to make it exported to keep it accessible. Note that all of this is still under internal
, so I don't think this expands the public API.
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 based the builderstest
naming convention on componenttest
, connectortest
, consumertest
, etc. Do you think I should make it a child of builders
instead of a sibling?
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.
builderstest -> is the test files, not testing helpers
I want us to be able to mark extension as 1.0 as soon as we mark component 1.0, so I am marking this as release blocker for the next release. I believe the changes discussed are all internal, so this is more of a reminder. |
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.
Change looks good, just need to update the deprecation version
@@ -388,6 +388,8 @@ func NewFactory(cfgType component.Type, createDefaultConfig component.CreateDefa | |||
|
|||
// MakeFactoryMap takes a list of connector factories and returns a map with factory type as keys. | |||
// It returns a non-nil error when there are factories with duplicate type. | |||
// | |||
// Deprecated: [v0.119.0] Use otelcol.MakeFactoryMap[connector.Factory] instead |
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.
// Deprecated: [v0.119.0] Use otelcol.MakeFactoryMap[connector.Factory] instead | |
// Deprecated: [v0.120.0] Use otelcol.MakeFactoryMap[connector.Factory] instead |
@@ -190,6 +190,8 @@ func NewFactory(cfgType component.Type, createDefaultConfig component.CreateDefa | |||
|
|||
// MakeFactoryMap takes a list of factories and returns a map with Factory type as keys. | |||
// It returns a non-nil error when there are factories with duplicate type. | |||
// | |||
// Deprecated: [v0.119.0] Use otelcol.MakeFactoryMap[exporter.Factory] instead |
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.
// Deprecated: [v0.119.0] Use otelcol.MakeFactoryMap[exporter.Factory] instead | |
// Deprecated: [v0.120.0] Use otelcol.MakeFactoryMap[exporter.Factory] instead |
@@ -82,6 +82,8 @@ func NewFactory( | |||
|
|||
// MakeFactoryMap takes a list of factories and returns a map with Factory type as keys. | |||
// It returns a non-nil error when there are factories with duplicate type. | |||
// | |||
// Deprecated: [v0.119.0] Use otelcol.MakeFactoryMap[extension.Factory] instead |
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.
// Deprecated: [v0.119.0] Use otelcol.MakeFactoryMap[extension.Factory] instead | |
// Deprecated: [v0.120.0] Use otelcol.MakeFactoryMap[extension.Factory] instead |
@@ -138,6 +138,8 @@ func NewFactory(cfgType component.Type, createDefaultConfig component.CreateDefa | |||
|
|||
// MakeFactoryMap takes a list of receiver factories and returns a map with factory type as keys. | |||
// It returns a non-nil error when there are factories with duplicate type. | |||
// | |||
// Deprecated: [v0.119.0] Use otelcol.MakeFactoryMap[scraper.Factory] instead |
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.
// Deprecated: [v0.119.0] Use otelcol.MakeFactoryMap[scraper.Factory] instead | |
// Deprecated: [v0.120.0] Use otelcol.MakeFactoryMap[scraper.Factory] instead |
@@ -200,6 +200,8 @@ func NewFactory(cfgType component.Type, createDefaultConfig component.CreateDefa | |||
|
|||
// MakeFactoryMap takes a list of receiver factories and returns a map with factory type as keys. | |||
// It returns a non-nil error when there are factories with duplicate type. | |||
// | |||
// Deprecated: [v0.119.0] Use otelcol.MakeFactoryMap[receiver.Factory] instead |
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.
// Deprecated: [v0.119.0] Use otelcol.MakeFactoryMap[receiver.Factory] instead | |
// Deprecated: [v0.120.0] Use otelcol.MakeFactoryMap[receiver.Factory] instead |
@@ -193,6 +193,8 @@ func NewFactory(cfgType component.Type, createDefaultConfig component.CreateDefa | |||
|
|||
// MakeFactoryMap takes a list of factories and returns a map with Factory type as keys. | |||
// It returns a non-nil error when there are factories with duplicate type. | |||
// | |||
// Deprecated: [v0.119.0] Use otelcol.MakeFactoryMap[processor.Factory] instead |
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.
// Deprecated: [v0.119.0] Use otelcol.MakeFactoryMap[processor.Factory] instead | |
// Deprecated: [v0.120.0] Use otelcol.MakeFactoryMap[processor.Factory] instead |
Description
At the moment,
receiver
,scraper
,processor
,exporter
, andextension
each have their own version of theMakeFactoryMap
function, which takes a list of Factories and returns it as a map, with the component name as the key (and an error if there is overlap). Because all versions are near-identical except for the Factory type used, and this function is only used in tests and in the code generated by OCB (components.go
), it was suggested to make it generic and move it to theotelcol
package.This PR does exactly that. The old
MakeFactoryMap
functions are deprecated (and may be removed alongside their tests in a future release). I also had to make a few other odd changes to fit the new dependency graph.Link to tracking issue
Resolves #12222