1
1
// Copyright The OpenTelemetry Authors
2
2
// SPDX-License-Identifier: Apache-2.0
3
3
4
- package attribute // import "go.opentelemetry.io/collector/service/internal/graph/ attribute"
4
+ package attribute // import "go.opentelemetry.io/collector/service/internal/attribute"
5
5
6
6
import (
7
- "fmt"
8
7
"hash/fnv"
9
8
10
9
"go.opentelemetry.io/otel/attribute"
10
+ "go.uber.org/zap"
11
11
12
12
"go.opentelemetry.io/collector/component"
13
13
"go.opentelemetry.io/collector/pipeline"
@@ -20,10 +20,6 @@ const (
20
20
signalKey = "otelcol.signal"
21
21
signalOutputKey = "otelcol.signal.output"
22
22
23
- receiverKind = "receiver"
24
- processorKind = "processor"
25
- exporterKind = "exporter"
26
- connectorKind = "connector"
27
23
capabiltiesKind = "capabilities"
28
24
fanoutKind = "fanout"
29
25
)
@@ -52,17 +48,32 @@ func (a Attributes) ID() int64 {
52
48
return a .id
53
49
}
54
50
51
+ func (a Attributes ) Logger (logger * zap.Logger ) * zap.Logger {
52
+ fields := make ([]zap.Field , 0 , a .set .Len ())
53
+ for _ , kv := range a .set .ToSlice () {
54
+ fields = append (fields , zap .String (string (kv .Key ), kv .Value .AsString ()))
55
+ }
56
+ return logger .With (fields ... )
57
+ }
58
+
55
59
func Receiver (pipelineType pipeline.Signal , id component.ID ) * Attributes {
56
60
return newAttributes (
57
- attribute .String (componentKindKey , receiverKind ),
61
+ attribute .String (componentKindKey , component . KindReceiver . String () ),
58
62
attribute .String (signalKey , pipelineType .String ()),
59
63
attribute .String (componentIDKey , id .String ()),
60
64
)
61
65
}
62
66
67
+ func ReceiverSingleton (id component.ID ) * Attributes {
68
+ return newAttributes (
69
+ attribute .String (componentKindKey , component .KindReceiver .String ()),
70
+ attribute .String (componentIDKey , id .String ()),
71
+ )
72
+ }
73
+
63
74
func Processor (pipelineID pipeline.ID , id component.ID ) * Attributes {
64
75
return newAttributes (
65
- attribute .String (componentKindKey , processorKind ),
76
+ attribute .String (componentKindKey , component . KindProcessor . String () ),
66
77
attribute .String (signalKey , pipelineID .Signal ().String ()),
67
78
attribute .String (pipelineIDKey , pipelineID .String ()),
68
79
attribute .String (componentIDKey , id .String ()),
@@ -71,16 +82,31 @@ func Processor(pipelineID pipeline.ID, id component.ID) *Attributes {
71
82
72
83
func Exporter (pipelineType pipeline.Signal , id component.ID ) * Attributes {
73
84
return newAttributes (
74
- attribute .String (componentKindKey , exporterKind ),
85
+ attribute .String (componentKindKey , component . KindExporter . String () ),
75
86
attribute .String (signalKey , pipelineType .String ()),
76
87
attribute .String (componentIDKey , id .String ()),
77
88
)
78
89
}
79
90
91
+ func ExporterSingleton (id component.ID ) * Attributes {
92
+ return newAttributes (
93
+ attribute .String (componentKindKey , component .KindExporter .String ()),
94
+ attribute .String (componentIDKey , id .String ()),
95
+ )
96
+ }
97
+
80
98
func Connector (exprPipelineType , rcvrPipelineType pipeline.Signal , id component.ID ) * Attributes {
81
99
return newAttributes (
82
- attribute .String (componentKindKey , connectorKind ),
83
- attribute .String (signalKey , fmt .Sprintf ("%s_to_%s" , exprPipelineType .String (), rcvrPipelineType .String ())),
100
+ attribute .String (componentKindKey , component .KindConnector .String ()),
101
+ attribute .String (signalKey , exprPipelineType .String ()),
102
+ attribute .String (signalOutputKey , rcvrPipelineType .String ()),
103
+ attribute .String (componentIDKey , id .String ()),
104
+ )
105
+ }
106
+
107
+ func ConnectorSingleton (id component.ID ) * Attributes {
108
+ return newAttributes (
109
+ attribute .String (componentKindKey , component .KindConnector .String ()),
84
110
attribute .String (componentIDKey , id .String ()),
85
111
)
86
112
}
@@ -98,3 +124,10 @@ func Fanout(pipelineID pipeline.ID) *Attributes {
98
124
attribute .String (pipelineIDKey , pipelineID .String ()),
99
125
)
100
126
}
127
+
128
+ func Extension (id component.ID ) * Attributes {
129
+ return newAttributes (
130
+ attribute .String (componentKindKey , component .KindExtension .String ()),
131
+ attribute .String (componentIDKey , id .String ()),
132
+ )
133
+ }
0 commit comments