diff --git a/reporter/base_reporter.go b/reporter/base_reporter.go index 9bef0268a..60b0d5b1a 100644 --- a/reporter/base_reporter.go +++ b/reporter/base_reporter.go @@ -123,6 +123,7 @@ func (b *baseReporter) ReportTraceEvent(trace *libpf.Trace, meta *samples.TraceE Timestamps: []uint64{uint64(meta.Timestamp)}, OffTimes: []int64{meta.OffTime}, EnvVars: meta.EnvVars, + Labels: trace.CustomLabels, } return nil } diff --git a/reporter/internal/pdata/generate.go b/reporter/internal/pdata/generate.go index 7d583c70d..73d9f227c 100644 --- a/reporter/internal/pdata/generate.go +++ b/reporter/internal/pdata/generate.go @@ -251,6 +251,14 @@ func (p *Pdata) setProfile( attribute.Key("process.environment_variable."+key), value) } + for key, value := range traceInfo.Labels { + // Once https://github.com/open-telemetry/semantic-conventions/issues/2561 + // reached an agreement, use the actual OTel SemConv attribute. + attrMgr.AppendOptionalString( + sample.AttributeIndices(), + attribute.Key("process.context.label."+key), + value) + } if p.ExtraSampleAttrProd != nil { extra := p.ExtraSampleAttrProd.ExtraSampleAttrs(attrMgr, traceKey.ExtraMeta) diff --git a/reporter/samples/samples.go b/reporter/samples/samples.go index 9851986d6..838783cd4 100644 --- a/reporter/samples/samples.go +++ b/reporter/samples/samples.go @@ -27,6 +27,7 @@ type TraceEvents struct { Timestamps []uint64 // in nanoseconds OffTimes []int64 // in nanoseconds EnvVars map[string]string + Labels map[string]string } // TraceAndMetaKey is the deduplication key for samples. This **must always**