Skip to content

Commit

Permalink
reporter: ensure that actively used executables do not expire
Browse files Browse the repository at this point in the history
  • Loading branch information
Gandem committed Nov 20, 2024
1 parent c9ac552 commit 1a8f02d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions reporter/otlp_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ import (
"go.opentelemetry.io/ebpf-profiler/libpf/xsync"
)

const (
executableCacheLifetime = 1 * time.Hour
)

var (
cgroupv2PathPattern = regexp.MustCompile(`0:.*?:(.*)`)
)
Expand Down Expand Up @@ -155,7 +159,7 @@ func NewOTLP(cfg *Config) (*OTLPReporter, error) {
if err != nil {
return nil, err
}
executables.SetLifetime(1 * time.Hour) // Allow GC to clean stale items.
executables.SetLifetime(executableCacheLifetime) // Allow GC to clean stale items.

frames, err := lru.NewSynced[libpf.FileID,
*xsync.RWMutex[map[libpf.AddressOrLineno]sourceInfo]](
Expand Down Expand Up @@ -582,7 +586,9 @@ func (r *OTLPReporter) getProfile() (profile *profiles.Profile, startTS, endTS u
fileIDtoMapping[traceInfo.files[i]] = idx
locationMappingIndex = idx

execInfo, exists := r.executables.Get(traceInfo.files[i])
// Ensure that actively used executables do not expire.
execInfo, exists := r.executables.GetAndRefresh(traceInfo.files[i],
executableCacheLifetime)

// Next step: Select a proper default value,
// if the name of the executable is not known yet.
Expand Down

0 comments on commit 1a8f02d

Please sign in to comment.