| 1 |
// Copyright The OpenTelemetry Authors |
| 2 |
// SPDX-License-Identifier: Apache-2.0 |
| 3 |
|
| 4 |
package graph // import "go.opentelemetry.io/collector/service/internal/graph" |
| 5 |
|
| 6 |
import ( |
| 7 |
"go.opentelemetry.io/collector/consumer" |
| 8 |
"go.opentelemetry.io/collector/consumer/xconsumer" |
| 9 |
"go.opentelemetry.io/collector/pipeline" |
| 10 |
"go.opentelemetry.io/collector/service/internal/attribute" |
| 11 |
) |
| 12 |
|
| 13 |
var _ consumerNode = (*capabilitiesNode)(nil) |
| 14 |
|
| 15 |
// Every pipeline has a "virtual" capabilities node immediately after the receiver(s). |
| 16 |
// There are two purposes for this node: |
| 17 |
// 1. Present aggregated capabilities to receivers, such as whether the pipeline mutates data. |
| 18 |
// 2. Present a consistent "first consumer" for each pipeline. |
| 19 |
// The nodeID is derived from "pipeline ID". |
| 20 |
type capabilitiesNode struct { |
| 21 |
attribute.Attributes |
| 22 |
pipelineID pipeline.ID |
| 23 |
baseConsumer |
| 24 |
consumer.ConsumeTracesFunc |
| 25 |
consumer.ConsumeMetricsFunc |
| 26 |
consumer.ConsumeLogsFunc |
| 27 |
xconsumer.ConsumeProfilesFunc |
| 28 |
} |
| 29 |
|
| 30 |
func newCapabilitiesNode(pipelineID pipeline.ID) *capabilitiesNode { |
| 31 |
return &capabilitiesNode{ |
| 32 |
Attributes: attribute.Capabilities(pipelineID), |
| 33 |
pipelineID: pipelineID, |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
func (n *capabilitiesNode) getConsumer() baseConsumer { |
| 38 |
return n |
| 39 |
} |