diff --git a/input/otlp/metrics.go b/input/otlp/metrics.go index c3802210..d3813830 100644 --- a/input/otlp/metrics.go +++ b/input/otlp/metrics.go @@ -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)) } diff --git a/input/otlp/metrics_test.go b/input/otlp/metrics_test.go index 6d669ff6..4198e0d9 100644 --- a/input/otlp/metrics_test.go +++ b/input/otlp/metrics_test.go @@ -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",