Skip to content

Commit 489868e

Browse files
authoredAug 12, 2024
Merge pull request #727 from atlassian/fix-tag-concat
assign new tag value after concat
2 parents 9cabc57 + 9760977 commit 489868e

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed
 

‎pkg/backends/otlp/backend.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func (bd *Backend) SendMetricsAsync(ctx context.Context, mm *gostatsd.MetricMap,
146146

147147
mm.Counters.Each(func(name, _ string, cm gostatsd.Counter) {
148148
if !cm.Tags.Exists("host") && cm.Source != "" {
149-
cm.Tags.Concat(gostatsd.Tags{"host:" + string(cm.Source)})
149+
cm.Tags = cm.Tags.Concat(gostatsd.Tags{"host:" + string(cm.Source)})
150150
}
151151
resources, attributes := data.SplitMetricTagsByKeysAndConvert(cm.Tags, bd.resourceKeys)
152152

@@ -176,7 +176,7 @@ func (bd *Backend) SendMetricsAsync(ctx context.Context, mm *gostatsd.MetricMap,
176176

177177
mm.Gauges.Each(func(name, _ string, gm gostatsd.Gauge) {
178178
if !gm.Tags.Exists("host") && gm.Source != "" {
179-
gm.Tags.Concat(gostatsd.Tags{"host:" + string(gm.Source)})
179+
gm.Tags = gm.Tags.Concat(gostatsd.Tags{"host:" + string(gm.Source)})
180180
}
181181
resources, attributes := data.SplitMetricTagsByKeysAndConvert(gm.Tags, bd.resourceKeys)
182182

@@ -195,7 +195,7 @@ func (bd *Backend) SendMetricsAsync(ctx context.Context, mm *gostatsd.MetricMap,
195195

196196
mm.Sets.Each(func(name, _ string, sm gostatsd.Set) {
197197
if !sm.Tags.Exists("host") && sm.Source != "" {
198-
sm.Tags.Concat(gostatsd.Tags{"host:" + string(sm.Source)})
198+
sm.Tags = sm.Tags.Concat(gostatsd.Tags{"host:" + string(sm.Source)})
199199
}
200200
resources, attributes := data.SplitMetricTagsByKeysAndConvert(sm.Tags, bd.resourceKeys)
201201

@@ -214,7 +214,7 @@ func (bd *Backend) SendMetricsAsync(ctx context.Context, mm *gostatsd.MetricMap,
214214

215215
mm.Timers.Each(func(name, _ string, t gostatsd.Timer) {
216216
if !t.Tags.Exists("host") && t.Source != "" {
217-
t.Tags.Concat(gostatsd.Tags{"host:" + string(t.Source)})
217+
t.Tags = t.Tags.Concat(gostatsd.Tags{"host:" + string(t.Source)})
218218
}
219219
resources, attributes := data.SplitMetricTagsByKeysAndConvert(t.Tags, bd.resourceKeys)
220220

‎pkg/backends/otlp/backend_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ func TestBackendSendAsyncMetrics(t *testing.T) {
331331
return
332332
}
333333

334-
assert.Error(t, fmt.Errorf("source attribute not found"))
334+
assert.Fail(t, "host attribute not found")
335335
}
336336
},
337337
enableHistograms: false,

0 commit comments

Comments
 (0)
Failed to load comments.