From b31b0846c348487687ecd5c1c3298a7d23ab6e87 Mon Sep 17 00:00:00 2001 From: Florian Lehner Date: Tue, 21 Jan 2025 16:22:36 +0100 Subject: [PATCH] reporter/collector: fix reporting issue If the OTel collector reports profiles it clears all map entries. So to be able to report new events, the base structure needs to exist. Signed-off-by: Florian Lehner --- reporter/collector_reporter.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/reporter/collector_reporter.go b/reporter/collector_reporter.go index 8bedb5bf..c5823fa9 100644 --- a/reporter/collector_reporter.go +++ b/reporter/collector_reporter.go @@ -113,7 +113,13 @@ func (r *CollectorReporter) GetMetrics() Metrics { func (r *CollectorReporter) reportProfile(ctx context.Context) error { traceEvents := r.traceEvents.WLock() events := maps.Clone(*traceEvents) + originsMap := make(map[libpf.Origin]samples.KeyToEventMapping, 2) clear(*traceEvents) + for _, origin := range []libpf.Origin{support.TraceOriginSampling, + support.TraceOriginOffCPU} { + originsMap[origin] = make(samples.KeyToEventMapping) + } + *traceEvents = originsMap r.traceEvents.WUnlock(&traceEvents) profiles := r.pdata.Generate(events)