Skip to content

Commit

Permalink
maint: remove trace cache metrics (#1447)
Browse files Browse the repository at this point in the history
## Which problem is this PR solving?

we are not using these metrics.
By removing them, we should also gain some CPU time back. Though, this
is not the driver for this change.

## Short description of the changes

- removing histogram metrics from trace cache
  • Loading branch information
VinozzZ authored Nov 25, 2024
1 parent dc650e9 commit 5c94037
Showing 1 changed file with 0 additions and 14 deletions.
14 changes: 0 additions & 14 deletions collect/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ var collectCacheMetrics = []metrics.Metadata{
{Name: "collect_cache_buffer_overrun", Type: metrics.Counter, Unit: metrics.Dimensionless, Description: "The number of times the trace overwritten in the circular buffer has not yet been sent"},
{Name: "collect_cache_capacity", Type: metrics.Gauge, Unit: metrics.Dimensionless, Description: "The number of traces that can be stored in the cache"},
{Name: "collect_cache_entries", Type: metrics.Histogram, Unit: metrics.Dimensionless, Description: "The number of traces currently stored in the cache"},
{Name: "trace_cache_set_dur_ms", Type: metrics.Histogram, Unit: metrics.Dimensionless, Description: "duration to set a trace in the cache"},
{Name: "trace_cache_take_expired_traces_dur_ms", Type: metrics.Histogram, Unit: metrics.Dimensionless, Description: "duration to take expired traces from the cache"},
{Name: "trace_cache_remove_traces_dur_ms", Type: metrics.Histogram, Unit: metrics.Dimensionless, Description: "duration to remove traces from the cache"},
{Name: "trace_cache_get_all_dur_ms", Type: metrics.Histogram, Unit: metrics.Dimensionless, Description: "duration to get all traces from the cache"},
}

func NewInMemCache(
Expand Down Expand Up @@ -95,9 +91,7 @@ func (d *DefaultInMemCache) Set(trace *types.Trace) {
if trace == nil {
return
}
start := time.Now()

defer d.Metrics.Histogram("trace_cache_set_dur_ms", float64(time.Since(start).Microseconds())/1000.0)
// update the cache and priority queue
d.cache[trace.TraceID] = trace
d.pq.Set(trace.TraceID, trace.SendBy)
Expand All @@ -111,9 +105,6 @@ func (d *DefaultInMemCache) Get(traceID string) *types.Trace {
// GetAll is not thread safe and should only be used when that's ok
// Returns all non-nil trace entries.
func (d *DefaultInMemCache) GetAll() []*types.Trace {
start := time.Now()

defer d.Metrics.Histogram("trace_cache_get_all_dur_ms", float64(time.Since(start).Microseconds())/1000.0)
return maps.Values(d.cache)
}

Expand All @@ -127,9 +118,6 @@ func (d *DefaultInMemCache) GetCacheCapacity() int {
func (d *DefaultInMemCache) TakeExpiredTraces(now time.Time, max int, filter func(*types.Trace) bool) []*types.Trace {
d.Metrics.Histogram("collect_cache_entries", float64(len(d.cache)))

start := time.Now()
defer d.Metrics.Histogram("trace_cache_take_expired_traces_dur_ms", float64(time.Since(start).Microseconds())/1000.0)

var expired, skipped []*types.Trace
for !d.pq.IsEmpty() && (max <= 0 || len(expired) < max) {
// pop the the next trace from the queue
Expand Down Expand Up @@ -173,8 +161,6 @@ func (d *DefaultInMemCache) TakeExpiredTraces(now time.Time, max int, filter fun
// the insertion list. This is used in the case of a cache overrun.
func (d *DefaultInMemCache) RemoveTraces(toDelete generics.Set[string]) {
d.Metrics.Histogram("collect_cache_entries", float64(len(d.cache)))
start := time.Now()
defer d.Metrics.Histogram("trace_cache_remove_traces_dur_ms", float64(time.Since(start).Microseconds())/1000.0)

for _, traceID := range toDelete.Members() {
delete(d.cache, traceID)
Expand Down

0 comments on commit 5c94037

Please sign in to comment.