Skip to content

Commit

Permalink
Allow datapoint attributes to override user.name (#317)
Browse files Browse the repository at this point in the history
  • Loading branch information
lahsivjar authored Jul 9, 2024
1 parent f3eac86 commit 1542936
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 5 additions & 0 deletions input/otlp/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,11 @@ func (c *Consumer) handleScopeMetrics(
event.Event = modelpb.EventFromVTPool()
}
event.Event.Dataset = v.Str()
case "user.name":
if event.User == nil {
event.User = modelpb.UserFromVTPool()
}
event.User.Name = truncate(v.Str())
default:
setLabel(k, event, ifaceAttributeValue(v))
}
Expand Down
3 changes: 0 additions & 3 deletions input/otlp/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1075,9 +1075,6 @@ func TestConsumeMetricsWithOTelRemapper(t *testing.T) {
},
Labels: map[string]*modelpb.LabelValue{
"otel_remapped": &modelpb.LabelValue{Value: "true"},
// This is set as labels too since the opentelemetry-lib
// adds `user.name` label to datapoints causing duplicates.
"user.name": &modelpb.LabelValue{Value: "testowner"},
},
Event: &modelpb.Event{
Dataset: "system.process",
Expand Down

0 comments on commit 1542936

Please sign in to comment.