mirror of
https://github.com/hanzoai/telemetry.git
synced 2026-10-30 20:01:49 +00:00
#### Description Depends on https://github.com/open-telemetry/opentelemetry-collector/pull/11209 This PR is a non-breaking implementation of https://github.com/open-telemetry/opentelemetry-collector/pull/10947. It adds a new module, `pipeline`, which houses a `pipeline.ID` and `pipeline.Signal`. `pipeline.ID` is used to identify a pipeline within the service. `pipeline.Signal` is uses to identify the signal associated to a pipeline. I do this work begrudgingly. As the PR shows, this is a huge refactor when done in a non-breaking way, will require 3 full releases, and doesn't benefit our [End Users or, in my opinion, our Component Developers or Collector Library Users](https://github.com/open-telemetry/opentelemetry-collector/blob/main/CONTRIBUTING.md#target-audiences). I view this refactor as a Nice-To-Have, not a requirement for Component 1.0. <!-- Issue number if applicable --> #### Link to tracking issue Works towards https://github.com/open-telemetry/opentelemetry-collector/issues/9429
38 lines
1.1 KiB
Go
38 lines
1.1 KiB
Go
// Copyright The OpenTelemetry Authors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package connector // import "go.opentelemetry.io/collector/connector"
|
|
|
|
import (
|
|
"go.opentelemetry.io/collector/connector/internal"
|
|
"go.opentelemetry.io/collector/consumer"
|
|
"go.opentelemetry.io/collector/internal/fanoutconsumer"
|
|
"go.opentelemetry.io/collector/pipeline"
|
|
)
|
|
|
|
// TracesRouterAndConsumer feeds the first consumer.Traces in each of the specified pipelines.
|
|
type TracesRouterAndConsumer interface {
|
|
consumer.Traces
|
|
Consumer(...pipeline.ID) (consumer.Traces, error)
|
|
PipelineIDs() []pipeline.ID
|
|
privateFunc()
|
|
}
|
|
|
|
type tracesRouter struct {
|
|
consumer.Traces
|
|
internal.BaseRouter[consumer.Traces]
|
|
}
|
|
|
|
func NewTracesRouter(cm map[pipeline.ID]consumer.Traces) TracesRouterAndConsumer {
|
|
consumers := make([]consumer.Traces, 0, len(cm))
|
|
for _, cons := range cm {
|
|
consumers = append(consumers, cons)
|
|
}
|
|
return &tracesRouter{
|
|
Traces: fanoutconsumer.NewTraces(consumers),
|
|
BaseRouter: internal.NewBaseRouter(fanoutconsumer.NewTraces, cm),
|
|
}
|
|
}
|
|
|
|
func (r *tracesRouter) privateFunc() {}
|