Skip to content

Commit

Permalink
statsdreceiver: update labels -> attributes (#4611)
Browse files Browse the repository at this point in the history
Following the changes in core to OTLP 0.9.0 to move away from `Labels` and on to `Attributes`

**Link to tracking Issue:** Part of open-telemetry/opentelemetry-collector#3535
  • Loading branch information
alrex committed Aug 13, 2021
1 parent fed3fdb commit 220ebf9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions receiver/statsdreceiver/protocol/metric_translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func buildCounterMetric(parsedMetric statsDMetric, isMonotonicCounter bool, time
dp.SetIntVal(parsedMetric.intvalue)
dp.SetTimestamp(pdata.TimestampFromTime(timeNow))
for i, key := range parsedMetric.labelKeys {
dp.LabelsMap().Insert(key, parsedMetric.labelValues[i])
dp.Attributes().InsertString(key, parsedMetric.labelValues[i])
}

return ilm
Expand All @@ -59,7 +59,7 @@ func buildGaugeMetric(parsedMetric statsDMetric, timeNow time.Time) pdata.Instru
dp.SetDoubleVal(parsedMetric.floatvalue)
dp.SetTimestamp(pdata.TimestampFromTime(timeNow))
for i, key := range parsedMetric.labelKeys {
dp.LabelsMap().Insert(key, parsedMetric.labelValues[i])
dp.Attributes().InsertString(key, parsedMetric.labelValues[i])
}

return ilm
Expand All @@ -77,7 +77,7 @@ func buildSummaryMetric(summaryMetric summaryMetric) pdata.InstrumentationLibrar
dp.SetSum(sum)
dp.SetTimestamp(pdata.TimestampFromTime(summaryMetric.timeNow))
for i, key := range summaryMetric.labelKeys {
dp.LabelsMap().Insert(key, summaryMetric.labelValues[i])
dp.Attributes().InsertString(key, summaryMetric.labelValues[i])
}

quantile := []float64{0, 10, 50, 90, 95, 100}
Expand Down
8 changes: 4 additions & 4 deletions receiver/statsdreceiver/protocol/metric_translator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestBuildCounterMetric(t *testing.T) {
dp := expectedMetric.Sum().DataPoints().AppendEmpty()
dp.SetIntVal(32)
dp.SetTimestamp(pdata.TimestampFromTime(timeNow))
dp.LabelsMap().Insert("mykey", "myvalue")
dp.Attributes().InsertString("mykey", "myvalue")
assert.Equal(t, metric, expectedMetrics)
}

Expand All @@ -71,8 +71,8 @@ func TestBuildGaugeMetric(t *testing.T) {
dp := expectedMetric.Gauge().DataPoints().AppendEmpty()
dp.SetDoubleVal(32.3)
dp.SetTimestamp(pdata.TimestampFromTime(timeNow))
dp.LabelsMap().Insert("mykey", "myvalue")
dp.LabelsMap().Insert("mykey2", "myvalue2")
dp.Attributes().InsertString("mykey", "myvalue")
dp.Attributes().InsertString("mykey2", "myvalue2")
assert.Equal(t, metric, expectedMetrics)
}

Expand All @@ -97,7 +97,7 @@ func TestBuildSummaryMetric(t *testing.T) {
dp.SetCount(6)
dp.SetTimestamp(pdata.TimestampFromTime(timeNow))
for i, key := range oneSummaryMetric.labelKeys {
dp.LabelsMap().Insert(key, oneSummaryMetric.labelValues[i])
dp.Attributes().InsertString(key, oneSummaryMetric.labelValues[i])
}
quantile := []float64{0, 10, 50, 90, 95, 100}
value := []float64{1, 1, 3, 6, 6, 6}
Expand Down

0 comments on commit 220ebf9

Please sign in to comment.