Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename struct traceFramesCounts -> traceEvents #133

Merged
merged 4 commits into from
Sep 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions reporter/otlp_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ type traceAndMetaKey struct {
containerID string
}

// traceFramesCounts holds known information about a trace.
type traceFramesCounts struct {
// traceEvents holds known information about a trace.
type traceEvents struct {
files []libpf.FileID
linenos []libpf.AddressOrLineno
frameTypes []libpf.FrameType
Expand Down Expand Up @@ -124,7 +124,7 @@ type OTLPReporter struct {
frames *lru.SyncedLRU[libpf.FileID, *xsync.RWMutex[map[libpf.AddressOrLineno]sourceInfo]]

// traceEvents stores reported trace events (trace metadata with frames and counts)
traceEvents xsync.RWMutex[map[traceAndMetaKey]*traceFramesCounts]
traceEvents xsync.RWMutex[map[traceAndMetaKey]*traceEvents]

// pkgGRPCOperationTimeout sets the time limit for GRPC requests.
pkgGRPCOperationTimeout time.Duration
Expand Down Expand Up @@ -156,8 +156,8 @@ func (r *OTLPReporter) SupportsReportTraceEvent() bool { return true }

// ReportTraceEvent enqueues reported trace events for the OTLP reporter.
func (r *OTLPReporter) ReportTraceEvent(trace *libpf.Trace, meta *TraceEventMeta) {
traceEvents := r.traceEvents.WLock()
defer r.traceEvents.WUnlock(&traceEvents)
traceEventsMap := r.traceEvents.WLock()
defer r.traceEvents.WUnlock(&traceEventsMap)

containerID, err := r.lookupCgroupv2(meta.PID)
if err != nil {
Expand All @@ -172,13 +172,13 @@ func (r *OTLPReporter) ReportTraceEvent(trace *libpf.Trace, meta *TraceEventMeta
containerID: containerID,
}

if tr, exists := (*traceEvents)[key]; exists {
tr.timestamps = append(tr.timestamps, uint64(meta.Timestamp))
(*traceEvents)[key] = tr
if events, exists := (*traceEventsMap)[key]; exists {
events.timestamps = append(events.timestamps, uint64(meta.Timestamp))
(*traceEventsMap)[key] = events
return
}

(*traceEvents)[key] = &traceFramesCounts{
(*traceEventsMap)[key] = &traceEvents{
files: trace.Files,
linenos: trace.Linenos,
frameTypes: trace.FrameTypes,
Expand Down Expand Up @@ -338,7 +338,7 @@ func Start(mainCtx context.Context, cfg *Config) (Reporter, error) {
executables: executables,
frames: frames,
hostmetadata: hostmetadata,
traceEvents: xsync.NewRWMutex(map[traceAndMetaKey]*traceFramesCounts{}),
traceEvents: xsync.NewRWMutex(map[traceAndMetaKey]*traceEvents{}),
cgroupv2ID: cgroupv2ID,
}

Expand Down