Skip to content

Commit

Permalink
[receiver/splunk_hec] Fix parsing of a single metric value payload (o…
Browse files Browse the repository at this point in the history
…pen-telemetry#33096)

Remove redundant `_value` attribute as it's set in the datapoint value.

Fixes
open-telemetry#33084
  • Loading branch information
dmitryax authored May 16, 2024
1 parent c3b68d6 commit ebee48b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion receiver/splunkhecreceiver/splunkhec_to_metricdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func buildAttributes(dimensions map[string]any) pcommon.Map {
attributes.EnsureCapacity(len(dimensions))
for key, val := range dimensions {

if strings.HasPrefix(key, "metric_name") {
if strings.HasPrefix(key, "metric_name") || key == "_value" {
continue
}
if key == "" || val == nil {
Expand Down
13 changes: 13 additions & 0 deletions receiver/splunkhecreceiver/splunkhec_to_metricdata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ func Test_splunkV2ToMetricsData(t *testing.T) {
wantMetricsData: buildDefaultMetricsData(nanos),
hecConfig: defaultTestingHecConfig,
},
{
name: "int_gauge_v7",
splunkDataPoint: func() *splunk.Event {
pt := buildDefaultSplunkDataPt()
delete(pt.Fields, "metric_name:single")
pt.Fields["metric_name"] = "single"
pt.Fields["_value"] = int64Ptr(13)
return pt

}(),
wantMetricsData: buildDefaultMetricsData(nanos),
hecConfig: defaultTestingHecConfig,
},
{
name: "multiple",
splunkDataPoint: func() *splunk.Event {
Expand Down

0 comments on commit ebee48b

Please sign in to comment.