Skip to content

Commit 56c7da2

Browse files
authored
[chore] Update obsconsumer to use new attribute name (#12959)
Implements new name for attribute as documented in #12951. Note: The obsconsumer package is unused until #12812 is merged so this is not a breaking change.
1 parent 29aaad3 commit 56c7da2

File tree

5 files changed

+22
-18
lines changed

5 files changed

+22
-18
lines changed

service/internal/obsconsumer/logs_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func TestLogsConsumeSuccess(t *testing.T) {
6767

6868
attrs := data.DataPoints[0].Attributes
6969
require.Equal(t, 1, attrs.Len())
70-
val, ok := attrs.Value(attribute.Key("outcome"))
70+
val, ok := attrs.Value(attribute.Key(obsconsumer.ComponentOutcome))
7171
require.True(t, ok)
7272
require.Equal(t, "success", val.Emit())
7373
}
@@ -108,7 +108,7 @@ func TestLogsConsumeFailure(t *testing.T) {
108108

109109
attrs := data.DataPoints[0].Attributes
110110
require.Equal(t, 1, attrs.Len())
111-
val, ok := attrs.Value(attribute.Key("outcome"))
111+
val, ok := attrs.Value(attribute.Key(obsconsumer.ComponentOutcome))
112112
require.True(t, ok)
113113
require.Equal(t, "failure", val.Emit())
114114
}
@@ -152,7 +152,7 @@ func TestLogsWithStaticAttributes(t *testing.T) {
152152
val, ok := attrs.Value(attribute.Key("test"))
153153
require.True(t, ok)
154154
require.Equal(t, "value", val.Emit())
155-
val, ok = attrs.Value(attribute.Key("outcome"))
155+
val, ok = attrs.Value(attribute.Key(obsconsumer.ComponentOutcome))
156156
require.True(t, ok)
157157
require.Equal(t, "success", val.Emit())
158158
}
@@ -224,7 +224,7 @@ func TestLogsMultipleItemsMixedOutcomes(t *testing.T) {
224224
// Find success and failure data points
225225
var successDP, failureDP metricdata.DataPoint[int64]
226226
for _, dp := range data.DataPoints {
227-
val, ok := dp.Attributes.Value(attribute.Key("outcome"))
227+
val, ok := dp.Attributes.Value(attribute.Key(obsconsumer.ComponentOutcome))
228228
if ok && val.Emit() == "success" {
229229
successDP = dp
230230
} else {

service/internal/obsconsumer/metrics_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func TestMetricsConsumeSuccess(t *testing.T) {
6868

6969
attrs := data.DataPoints[0].Attributes
7070
require.Equal(t, 1, attrs.Len())
71-
val, ok := attrs.Value(attribute.Key("outcome"))
71+
val, ok := attrs.Value(attribute.Key(obsconsumer.ComponentOutcome))
7272
require.True(t, ok)
7373
require.Equal(t, "success", val.Emit())
7474
}
@@ -110,7 +110,7 @@ func TestMetricsConsumeFailure(t *testing.T) {
110110

111111
attrs := data.DataPoints[0].Attributes
112112
require.Equal(t, 1, attrs.Len())
113-
val, ok := attrs.Value(attribute.Key("outcome"))
113+
val, ok := attrs.Value(attribute.Key(obsconsumer.ComponentOutcome))
114114
require.True(t, ok)
115115
require.Equal(t, "failure", val.Emit())
116116
}
@@ -156,7 +156,7 @@ func TestMetricsWithStaticAttributes(t *testing.T) {
156156
val, ok := attrs.Value(attribute.Key("test"))
157157
require.True(t, ok)
158158
require.Equal(t, "value", val.Emit())
159-
val, ok = attrs.Value(attribute.Key("outcome"))
159+
val, ok = attrs.Value(attribute.Key(obsconsumer.ComponentOutcome))
160160
require.True(t, ok)
161161
require.Equal(t, "success", val.Emit())
162162
}
@@ -232,7 +232,7 @@ func TestMetricsMultipleItemsMixedOutcomes(t *testing.T) {
232232
// Find success and failure data points
233233
var successDP, failureDP metricdata.DataPoint[int64]
234234
for _, dp := range data.DataPoints {
235-
val, ok := dp.Attributes.Value(attribute.Key("outcome"))
235+
val, ok := dp.Attributes.Value(attribute.Key(obsconsumer.ComponentOutcome))
236236
if ok && val.Emit() == "success" {
237237
successDP = dp
238238
} else {

service/internal/obsconsumer/option.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ import (
88
"go.opentelemetry.io/otel/metric"
99
)
1010

11+
const (
12+
ComponentOutcome = "otelcol.component.outcome"
13+
)
14+
1115
// Option modifies the consumer behavior.
1216
type Option interface {
1317
apply(*options)
@@ -35,11 +39,11 @@ type compiledOptions struct {
3539

3640
func (o *options) compile() compiledOptions {
3741
successAttrs := make([]attribute.KeyValue, 0, 1+len(o.staticDataPointAttributes))
38-
successAttrs = append(successAttrs, attribute.String("outcome", "success"))
42+
successAttrs = append(successAttrs, attribute.String(ComponentOutcome, "success"))
3943
successAttrs = append(successAttrs, o.staticDataPointAttributes...)
4044

4145
failureAttrs := make([]attribute.KeyValue, 0, 1+len(o.staticDataPointAttributes))
42-
failureAttrs = append(failureAttrs, attribute.String("outcome", "failure"))
46+
failureAttrs = append(failureAttrs, attribute.String(ComponentOutcome, "failure"))
4347
failureAttrs = append(failureAttrs, o.staticDataPointAttributes...)
4448

4549
return compiledOptions{

service/internal/obsconsumer/profiles_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func TestProfilesConsumeSuccess(t *testing.T) {
6767

6868
attrs := data.DataPoints[0].Attributes
6969
require.Equal(t, 1, attrs.Len())
70-
val, ok := attrs.Value(attribute.Key("outcome"))
70+
val, ok := attrs.Value(attribute.Key(obsconsumer.ComponentOutcome))
7171
require.True(t, ok)
7272
require.Equal(t, "success", val.Emit())
7373
}
@@ -108,7 +108,7 @@ func TestProfilesConsumeFailure(t *testing.T) {
108108

109109
attrs := data.DataPoints[0].Attributes
110110
require.Equal(t, 1, attrs.Len())
111-
val, ok := attrs.Value(attribute.Key("outcome"))
111+
val, ok := attrs.Value(attribute.Key(obsconsumer.ComponentOutcome))
112112
require.True(t, ok)
113113
require.Equal(t, "failure", val.Emit())
114114
}
@@ -152,7 +152,7 @@ func TestProfilesWithStaticAttributes(t *testing.T) {
152152
val, ok := attrs.Value(attribute.Key("test"))
153153
require.True(t, ok)
154154
require.Equal(t, "value", val.Emit())
155-
val, ok = attrs.Value(attribute.Key("outcome"))
155+
val, ok = attrs.Value(attribute.Key(obsconsumer.ComponentOutcome))
156156
require.True(t, ok)
157157
require.Equal(t, "success", val.Emit())
158158
}
@@ -224,7 +224,7 @@ func TestProfilesMultipleItemsMixedOutcomes(t *testing.T) {
224224
// Find success and failure data points
225225
var successDP, failureDP metricdata.DataPoint[int64]
226226
for _, dp := range data.DataPoints {
227-
val, ok := dp.Attributes.Value(attribute.Key("outcome"))
227+
val, ok := dp.Attributes.Value(attribute.Key(obsconsumer.ComponentOutcome))
228228
if ok && val.Emit() == "success" {
229229
successDP = dp
230230
} else {

service/internal/obsconsumer/traces_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func TestTracesConsumeSuccess(t *testing.T) {
6767

6868
attrs := data.DataPoints[0].Attributes
6969
require.Equal(t, 1, attrs.Len())
70-
val, ok := attrs.Value(attribute.Key("outcome"))
70+
val, ok := attrs.Value(attribute.Key(obsconsumer.ComponentOutcome))
7171
require.True(t, ok)
7272
require.Equal(t, "success", val.Emit())
7373
}
@@ -108,7 +108,7 @@ func TestTracesConsumeFailure(t *testing.T) {
108108

109109
attrs := data.DataPoints[0].Attributes
110110
require.Equal(t, 1, attrs.Len())
111-
val, ok := attrs.Value(attribute.Key("outcome"))
111+
val, ok := attrs.Value(attribute.Key(obsconsumer.ComponentOutcome))
112112
require.True(t, ok)
113113
require.Equal(t, "failure", val.Emit())
114114
}
@@ -152,7 +152,7 @@ func TestTracesWithStaticAttributes(t *testing.T) {
152152
val, ok := attrs.Value(attribute.Key("test"))
153153
require.True(t, ok)
154154
require.Equal(t, "value", val.Emit())
155-
val, ok = attrs.Value(attribute.Key("outcome"))
155+
val, ok = attrs.Value(attribute.Key(obsconsumer.ComponentOutcome))
156156
require.True(t, ok)
157157
require.Equal(t, "success", val.Emit())
158158
}
@@ -224,7 +224,7 @@ func TestTracesMultipleItemsMixedOutcomes(t *testing.T) {
224224
// Find success and failure data points
225225
var successDP, failureDP metricdata.DataPoint[int64]
226226
for _, dp := range data.DataPoints {
227-
val, ok := dp.Attributes.Value(attribute.Key("outcome"))
227+
val, ok := dp.Attributes.Value(attribute.Key(obsconsumer.ComponentOutcome))
228228
if ok && val.Emit() == "success" {
229229
successDP = dp
230230
} else {

0 commit comments

Comments
 (0)