mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Implement review feedback
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
parent
6c0910a289
commit
25e2c05a47
|
@ -94,7 +94,7 @@ func (c *PostingsForMatchersCache) PostingsForMatchers(ctx context.Context, ix I
|
||||||
span.RecordError(err)
|
span.RecordError(err)
|
||||||
return p, err
|
return p, err
|
||||||
}
|
}
|
||||||
c.expire(ctx)
|
c.expire()
|
||||||
p, err := c.postingsForMatchersPromise(ctx, ix, ms)(ctx)
|
p, err := c.postingsForMatchersPromise(ctx, ix, ms)(ctx)
|
||||||
span.RecordError(err)
|
span.RecordError(err)
|
||||||
return p, err
|
return p, err
|
||||||
|
@ -190,20 +190,13 @@ type postingsForMatchersCachedCall struct {
|
||||||
sizeBytes int64
|
sizeBytes int64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *PostingsForMatchersCache) expire(ctx context.Context) {
|
func (c *PostingsForMatchersCache) expire() {
|
||||||
_, span := otel.Tracer("").Start(ctx, "PostingsForMatchersCache.expire", trace.WithAttributes(
|
|
||||||
attribute.Stringer("ttl", c.ttl),
|
|
||||||
))
|
|
||||||
defer span.End()
|
|
||||||
|
|
||||||
if c.ttl <= 0 {
|
if c.ttl <= 0 {
|
||||||
span.AddEvent("ttl < 0 - doing nothing")
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
c.cachedMtx.RLock()
|
c.cachedMtx.RLock()
|
||||||
if !c.shouldEvictHead() {
|
if !c.shouldEvictHead() {
|
||||||
span.AddEvent("should not evict head")
|
|
||||||
c.cachedMtx.RUnlock()
|
c.cachedMtx.RUnlock()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -212,7 +205,6 @@ func (c *PostingsForMatchersCache) expire(ctx context.Context) {
|
||||||
c.cachedMtx.Lock()
|
c.cachedMtx.Lock()
|
||||||
defer c.cachedMtx.Unlock()
|
defer c.cachedMtx.Unlock()
|
||||||
|
|
||||||
span.AddEvent("evicting head(s)")
|
|
||||||
for c.shouldEvictHead() {
|
for c.shouldEvictHead() {
|
||||||
c.evictHead()
|
c.evictHead()
|
||||||
}
|
}
|
||||||
|
@ -246,8 +238,7 @@ func (c *PostingsForMatchersCache) evictHead() {
|
||||||
// created has to be called when returning from the PostingsForMatchers call that creates the promise.
|
// created has to be called when returning from the PostingsForMatchers call that creates the promise.
|
||||||
// the ts provided should be the call time.
|
// the ts provided should be the call time.
|
||||||
func (c *PostingsForMatchersCache) created(ctx context.Context, key string, ts time.Time, sizeBytes int64) {
|
func (c *PostingsForMatchersCache) created(ctx context.Context, key string, ts time.Time, sizeBytes int64) {
|
||||||
_, span := otel.Tracer("").Start(ctx, "PostingsForMatchersCache.created")
|
span := trace.SpanFromContext(ctx)
|
||||||
defer span.End()
|
|
||||||
|
|
||||||
if c.ttl <= 0 {
|
if c.ttl <= 0 {
|
||||||
span.AddEvent("deleting cached promise since c.ttl <= 0", trace.WithAttributes(
|
span.AddEvent("deleting cached promise since c.ttl <= 0", trace.WithAttributes(
|
||||||
|
|
Loading…
Reference in a new issue