Skip to content

Commit

Permalink
Merge pull request #825 from grafana/track-cached-promise-completion-…
Browse files Browse the repository at this point in the history
…timestamp-in-trace

Track PostingsForMatchers cached promise completion timestamp in trace
  • Loading branch information
pracucci authored Jan 28, 2025
2 parents 127392e + 8982998 commit 8d21000
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tsdb/postings_for_matchers_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ func (p *postingsForMatcherPromise) result(ctx context.Context) (index.Postings,
if p.err != nil {
return nil, fmt.Errorf("postingsForMatchers promise completed with error: %w", p.err)
}

trace.SpanFromContext(ctx).AddEvent("completed postingsForMatchers promise", trace.WithAttributes(
// Do not format the timestamp to introduce a performance regression.
attribute.Int64("evaluation completed at (epoch seconds)", p.evaluationCompletedAt.Unix()),
))

return p.cloner.Clone(), nil
}
}
Expand Down Expand Up @@ -264,7 +270,7 @@ func (c *PostingsForMatchersCache) postingsForMatchersPromise(ctx context.Contex
}

c.metrics.hits.Inc()
span.AddEvent("using cached postingsForMatchers promise", trace.WithAttributes(
span.AddEvent("waiting cached postingsForMatchers promise", trace.WithAttributes(
attribute.String("cache_key", key),
))

Expand Down

0 comments on commit 8d21000

Please sign in to comment.