Skip to content

Commit a9e6e21

Browse files
committed
Fix 'otelcol.component.kind' value capitalization
1 parent 70e22a3 commit a9e6e21

File tree

4 files changed

+42
-16
lines changed

4 files changed

+42
-16
lines changed

.chloggen/fix-attribute-cap.yaml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: breaking
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
7+
component: service
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Lowercase values for 'otelcol.component.kind' attributes.
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [12865]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# Optional: The change log or logs in which this entry should be included.
21+
# e.g. '[user]' or '[user, api]'
22+
# Include 'user' if the change is relevant to end users.
23+
# Include 'api' if there is a change to a library API.
24+
# Default: '[user]'
25+
change_logs: []

service/internal/attribute/attribute.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package attribute // import "go.opentelemetry.io/collector/service/internal/attr
55

66
import (
77
"hash/fnv"
8+
"strings"
89

910
"go.opentelemetry.io/otel/attribute"
1011

@@ -44,15 +45,15 @@ func (a Attributes) ID() int64 {
4445

4546
func Receiver(pipelineType pipeline.Signal, id component.ID) Attributes {
4647
return newAttributes(
47-
attribute.String(componentattribute.ComponentKindKey, component.KindReceiver.String()),
48+
attribute.String(componentattribute.ComponentKindKey, strings.ToLower(component.KindReceiver.String())),
4849
attribute.String(componentattribute.SignalKey, pipelineType.String()),
4950
attribute.String(componentattribute.ComponentIDKey, id.String()),
5051
)
5152
}
5253

5354
func Processor(pipelineID pipeline.ID, id component.ID) Attributes {
5455
return newAttributes(
55-
attribute.String(componentattribute.ComponentKindKey, component.KindProcessor.String()),
56+
attribute.String(componentattribute.ComponentKindKey, strings.ToLower(component.KindProcessor.String())),
5657
attribute.String(componentattribute.SignalKey, pipelineID.Signal().String()),
5758
attribute.String(componentattribute.PipelineIDKey, pipelineID.String()),
5859
attribute.String(componentattribute.ComponentIDKey, id.String()),
@@ -61,15 +62,15 @@ func Processor(pipelineID pipeline.ID, id component.ID) Attributes {
6162

6263
func Exporter(pipelineType pipeline.Signal, id component.ID) Attributes {
6364
return newAttributes(
64-
attribute.String(componentattribute.ComponentKindKey, component.KindExporter.String()),
65+
attribute.String(componentattribute.ComponentKindKey, strings.ToLower(component.KindExporter.String())),
6566
attribute.String(componentattribute.SignalKey, pipelineType.String()),
6667
attribute.String(componentattribute.ComponentIDKey, id.String()),
6768
)
6869
}
6970

7071
func Connector(exprPipelineType, rcvrPipelineType pipeline.Signal, id component.ID) Attributes {
7172
return newAttributes(
72-
attribute.String(componentattribute.ComponentKindKey, component.KindConnector.String()),
73+
attribute.String(componentattribute.ComponentKindKey, strings.ToLower(component.KindConnector.String())),
7374
attribute.String(componentattribute.SignalKey, exprPipelineType.String()),
7475
attribute.String(componentattribute.SignalOutputKey, rcvrPipelineType.String()),
7576
attribute.String(componentattribute.ComponentIDKey, id.String()),
@@ -78,7 +79,7 @@ func Connector(exprPipelineType, rcvrPipelineType pipeline.Signal, id component.
7879

7980
func Extension(id component.ID) Attributes {
8081
return newAttributes(
81-
attribute.String(componentattribute.ComponentKindKey, component.KindExtension.String()),
82+
attribute.String(componentattribute.ComponentKindKey, strings.ToLower(component.KindExtension.String())),
8283
attribute.String(componentattribute.ComponentIDKey, id.String()),
8384
)
8485
}

service/internal/attribute/attribute_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func TestReceiver(t *testing.T) {
4747
r := attribute.Receiver(sig, id)
4848
componentKind, ok := r.Set().Value(componentattribute.ComponentKindKey)
4949
require.True(t, ok)
50-
require.Equal(t, component.KindReceiver.String(), componentKind.AsString())
50+
require.Equal(t, "receiver", componentKind.AsString())
5151

5252
signal, ok := r.Set().Value(componentattribute.SignalKey)
5353
require.True(t, ok)
@@ -66,7 +66,7 @@ func TestProcessor(t *testing.T) {
6666
p := attribute.Processor(pID, id)
6767
componentKind, ok := p.Set().Value(componentattribute.ComponentKindKey)
6868
require.True(t, ok)
69-
require.Equal(t, component.KindProcessor.String(), componentKind.AsString())
69+
require.Equal(t, "processor", componentKind.AsString())
7070

7171
pipelineID, ok := p.Set().Value(componentattribute.PipelineIDKey)
7272
require.True(t, ok)
@@ -85,7 +85,7 @@ func TestExporter(t *testing.T) {
8585
e := attribute.Exporter(sig, id)
8686
componentKind, ok := e.Set().Value(componentattribute.ComponentKindKey)
8787
require.True(t, ok)
88-
require.Equal(t, component.KindExporter.String(), componentKind.AsString())
88+
require.Equal(t, "exporter", componentKind.AsString())
8989

9090
signal, ok := e.Set().Value(componentattribute.SignalKey)
9191
require.True(t, ok)
@@ -105,7 +105,7 @@ func TestConnector(t *testing.T) {
105105
c := attribute.Connector(exprSig, rcvrSig, id)
106106
componentKind, ok := c.Set().Value(componentattribute.ComponentKindKey)
107107
require.True(t, ok)
108-
require.Equal(t, component.KindConnector.String(), componentKind.AsString())
108+
require.Equal(t, "connector", componentKind.AsString())
109109

110110
signal, ok := c.Set().Value(componentattribute.SignalKey)
111111
require.True(t, ok)
@@ -127,7 +127,7 @@ func TestExtension(t *testing.T) {
127127
e := attribute.Extension(component.MustNewID("foo"))
128128
componentKind, ok := e.Set().Value(componentattribute.ComponentKindKey)
129129
require.True(t, ok)
130-
require.Equal(t, component.KindExtension.String(), componentKind.AsString())
130+
require.Equal(t, "extension", componentKind.AsString())
131131
}
132132

133133
func TestSetEquality(t *testing.T) {

service/internal/graph/graph_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -2231,11 +2231,11 @@ func TestGraphBuildErrors(t *testing.T) {
22312231
},
22322232
},
22332233
expected: `cycle detected: ` +
2234-
`connector "nop/conn" (traces to traces) -> ` +
2235-
`processor "nop" in pipeline "traces/1" -> ` +
22362234
`connector "nop/conn1" (traces to traces) -> ` +
22372235
`processor "nop" in pipeline "traces/2" -> ` +
2238-
`connector "nop/conn" (traces to traces)`,
2236+
`connector "nop/conn" (traces to traces) -> ` +
2237+
`processor "nop" in pipeline "traces/1" -> ` +
2238+
`connector "nop/conn1" (traces to traces)`,
22392239
},
22402240
{
22412241
name: "not_allowed_deep_cycle_metrics.yaml",
@@ -2321,11 +2321,11 @@ func TestGraphBuildErrors(t *testing.T) {
23212321
},
23222322
},
23232323
expected: `cycle detected: ` +
2324-
`connector "nop/conn1" (logs to logs) -> ` +
2325-
`processor "nop" in pipeline "logs/2" -> ` +
23262324
`connector "nop/conn" (logs to logs) -> ` +
23272325
`processor "nop" in pipeline "logs/1" -> ` +
2328-
`connector "nop/conn1" (logs to logs)`,
2326+
`connector "nop/conn1" (logs to logs) -> ` +
2327+
`processor "nop" in pipeline "logs/2" -> ` +
2328+
`connector "nop/conn" (logs to logs)`,
23292329
},
23302330
{
23312331
name: "not_allowed_deep_cycle_profiles.yaml",

0 commit comments

Comments
 (0)