Skip to content

Commit

Permalink
fix: fix prometheus formatter for non-string data point labels
Browse files Browse the repository at this point in the history
Signed-off-by: Dominik Rosiek <drosiek@sumologic.com>
  • Loading branch information
Dominik Rosiek committed Jan 18, 2024
1 parent e35d054 commit 8e41b8a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
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 8e41b8a

Please sign in to comment.