-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove circular dependency between default otel and connector
Signed-off-by: Bogdan Drutu <[email protected]>
- Loading branch information
1 parent
1d0d1ef
commit deb315f
Showing
36 changed files
with
746 additions
and
629 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Use this changelog template to create an entry for release notes. | ||
|
||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
change_type: 'deprecated' | ||
|
||
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) | ||
component: 'connector' | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: "Deprecate [Metrics|Logs|Traces]Router in favour of [Metrics|Logs|Traces]TracesRouterAndConsumer" | ||
|
||
# One or more tracking issues or pull requests related to the change | ||
issues: [9095] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Use this changelog template to create an entry for release notes. | ||
|
||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
change_type: 'breaking' | ||
|
||
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) | ||
component: "connector" | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: "Change interfaces connector.[Traces|Metrics|Logs]Router to disallow implementation" | ||
|
||
# One or more tracking issues or pull requests related to the change | ||
issues: [9095] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package connector // import "go.opentelemetry.io/collector/connector" | ||
|
||
import ( | ||
"fmt" | ||
|
||
"go.uber.org/multierr" | ||
|
||
"go.opentelemetry.io/collector/component" | ||
"go.opentelemetry.io/collector/consumer" | ||
"go.opentelemetry.io/collector/internal/fanoutconsumer" | ||
) | ||
|
||
// Deprecated: [v0.92.0] use LogsRouterAndConsumer | ||
type LogsRouter interface { | ||
Consumer(...component.ID) (consumer.Logs, error) | ||
PipelineIDs() []component.ID | ||
} | ||
|
||
// LogsRouterAndConsumer feeds the first consumer.Logs in each of the specified pipelines. | ||
type LogsRouterAndConsumer interface { | ||
consumer.Logs | ||
Consumer(...component.ID) (consumer.Logs, error) | ||
PipelineIDs() []component.ID | ||
privateFunc() | ||
} | ||
|
||
type logsRouter struct { | ||
consumer.Logs | ||
consumers map[component.ID]consumer.Logs | ||
} | ||
|
||
func NewLogsRouter(cm map[component.ID]consumer.Logs) LogsRouterAndConsumer { | ||
consumers := make([]consumer.Logs, 0, len(cm)) | ||
for _, consumer := range cm { | ||
consumers = append(consumers, consumer) | ||
} | ||
return &logsRouter{ | ||
Logs: fanoutconsumer.NewLogs(consumers), | ||
consumers: cm, | ||
} | ||
} | ||
|
||
func (r *logsRouter) PipelineIDs() []component.ID { | ||
ids := make([]component.ID, 0, len(r.consumers)) | ||
for id := range r.consumers { | ||
ids = append(ids, id) | ||
} | ||
return ids | ||
} | ||
|
||
func (r *logsRouter) Consumer(pipelineIDs ...component.ID) (consumer.Logs, error) { | ||
if len(pipelineIDs) == 0 { | ||
return nil, fmt.Errorf("missing consumers") | ||
} | ||
consumers := make([]consumer.Logs, 0, len(pipelineIDs)) | ||
var errors error | ||
for _, pipelineID := range pipelineIDs { | ||
c, ok := r.consumers[pipelineID] | ||
if ok { | ||
consumers = append(consumers, c) | ||
} else { | ||
errors = multierr.Append(errors, fmt.Errorf("missing consumer: %q", pipelineID)) | ||
} | ||
} | ||
if errors != nil { | ||
// TODO potentially this could return a NewLogs with the valid consumers | ||
return nil, errors | ||
} | ||
return fanoutconsumer.NewLogs(consumers), nil | ||
} | ||
|
||
func (r *logsRouter) privateFunc() {} |
Oops, something went wrong.