Skip to content

Commit

Permalink
fix(sumologicexporter): fix prometheus formatter for non-string data …
Browse files Browse the repository at this point in the history
…point labels (#1428)

* fix: fix prometheus formatter for non-string data point labels

Signed-off-by: Dominik Rosiek <drosiek@sumologic.com>

* chore: changelog

Signed-off-by: Dominik Rosiek <drosiek@sumologic.com>

* Rename 3646.fixed.txt to 1428.fixed.txt

* Update .changelog/1428.fixed.txt

---------

Signed-off-by: Dominik Rosiek <drosiek@sumologic.com>
  • Loading branch information
sumo-drosiek authored Jan 19, 2024
1 parent eea5c1d commit a9f3960
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions .changelog/1428.fixed.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fix(sumologicexporter): fix prometheus formatter for non-string data point
2 changes: 1 addition & 1 deletion pkg/exporter/sumologicexporter/prometheus_formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (f *prometheusFormatter) tags2String(attr pcommon.Map, labels pcommon.Map)

attr.CopyTo(mergedAttributes)
labels.Range(func(k string, v pcommon.Value) bool {
mergedAttributes.PutStr(k, v.Str())
mergedAttributes.PutStr(k, v.AsString())
return true
})
length := mergedAttributes.Len()
Expand Down
10 changes: 8 additions & 2 deletions pkg/exporter/sumologicexporter/prometheus_formatter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,16 @@ func TestTags2String(t *testing.T) {
require.NoError(t, err)

_, attributes := exampleIntMetric()
attributes.PutInt("int", 200)

labels := pcommon.NewMap()
labels.PutInt("l_int", 200)
labels.PutStr("l_str", "two")

assert.Equal(
t,
prometheusTags(`{test="test_value",test2="second_value"}`),
f.tags2String(attributes, pcommon.NewMap()),
prometheusTags(`{test="test_value",test2="second_value",int="200",l_int="200",l_str="two"}`),
f.tags2String(attributes, labels),
)
}

Expand Down

0 comments on commit a9f3960

Please sign in to comment.