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

maint: remove trace cache metrics #1447

Merged
merged 2 commits into from
Nov 25, 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
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