Skip to content

Commit

Permalink
reporter/collector: fix reporting issue
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
florianl committed Jan 21, 2025
1 parent 10b4b22 commit b31b084
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions reporter/collector_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b31b084

Please sign in to comment.