@@ -437,13 +437,14 @@ func initMemoryLayer(cacheSize int64, removeOnUpdate bool) *MemoryLayer {
437437 // Record the posting list cache hit ratio
438438 ostats .Record (context .Background (), x .PLCacheHitRatio .M (m .Ratio ()))
439439
440- x .NumPostingListCacheSave .M (ml .cache .numCacheRead .Load ())
441- ml .cache .numCacheSave .Store (0 )
440+ if EnableDetailedMetrics {
441+ x .NumPostingListCacheSave .M (ml .cache .numCacheRead .Load ())
442+ x .NumPostingListCacheRead .M (ml .cache .numCacheRead .Load ())
443+ x .NumPostingListCacheReadFail .M (ml .cache .numCacheReadFails .Load ())
444+ }
442445
443- x . NumPostingListCacheRead . M ( ml .cache .numCacheRead . Load () )
446+ ml .cache .numCacheSave . Store ( 0 )
444447 ml .cache .numCacheRead .Store (0 )
445-
446- x .NumPostingListCacheReadFail .M (ml .cache .numCacheReadFails .Load ())
447448 ml .cache .numCacheReadFails .Store (0 )
448449 }
449450 }()
@@ -547,10 +548,12 @@ func ReadPostingList(key []byte, it *badger.Iterator) (*List, error) {
547548 start := time .Now ()
548549 defer func () {
549550 ms := x .SinceMs (start )
550- var tags []tag.Mutator
551- tags = append (tags , tag .Upsert (x .KeyMethod , "iterate" ))
552- tags = append (tags , tag .Upsert (x .KeyStatus , pk .Attr ))
553- _ = ostats .RecordWithTags (context .Background (), tags , x .BadgerReadLatencyMs .M (ms ))
551+ if EnableDetailedMetrics {
552+ var tags []tag.Mutator
553+ tags = append (tags , tag .Upsert (x .KeyMethod , "iterate" ))
554+ tags = append (tags , tag .Upsert (x .KeyStatus , pk .Attr ))
555+ _ = ostats .RecordWithTags (context .Background (), tags , x .BadgerReadLatencyMs .M (ms ))
556+ }
554557 }()
555558
556559 if pk .HasStartUid {
0 commit comments