@@ -448,13 +448,14 @@ func initMemoryLayer(cacheSize int64, removeOnUpdate bool) *MemoryLayer {
448448 // Record the posting list cache hit ratio
449449 ostats .Record (context .Background (), x .PLCacheHitRatio .M (m .Ratio ()))
450450
451- x .NumPostingListCacheSave .M (ml .cache .numCacheRead .Load ())
452- ml .cache .numCacheSave .Store (0 )
451+ if EnableDetailedMetrics {
452+ x .NumPostingListCacheSave .M (ml .cache .numCacheRead .Load ())
453+ x .NumPostingListCacheRead .M (ml .cache .numCacheRead .Load ())
454+ x .NumPostingListCacheReadFail .M (ml .cache .numCacheReadFails .Load ())
455+ }
453456
454- x . NumPostingListCacheRead . M ( ml .cache .numCacheRead . Load () )
457+ ml .cache .numCacheSave . Store ( 0 )
455458 ml .cache .numCacheRead .Store (0 )
456-
457- x .NumPostingListCacheReadFail .M (ml .cache .numCacheReadFails .Load ())
458459 ml .cache .numCacheReadFails .Store (0 )
459460 }
460461 }()
@@ -558,10 +559,12 @@ func ReadPostingList(key []byte, it *badger.Iterator) (*List, error) {
558559 start := time .Now ()
559560 defer func () {
560561 ms := x .SinceMs (start )
561- var tags []tag.Mutator
562- tags = append (tags , tag .Upsert (x .KeyMethod , "iterate" ))
563- tags = append (tags , tag .Upsert (x .KeyStatus , pk .Attr ))
564- _ = ostats .RecordWithTags (context .Background (), tags , x .BadgerReadLatencyMs .M (ms ))
562+ if EnableDetailedMetrics {
563+ var tags []tag.Mutator
564+ tags = append (tags , tag .Upsert (x .KeyMethod , "iterate" ))
565+ tags = append (tags , tag .Upsert (x .KeyStatus , pk .Attr ))
566+ _ = ostats .RecordWithTags (context .Background (), tags , x .BadgerReadLatencyMs .M (ms ))
567+ }
565568 }()
566569
567570 if pk .HasStartUid {
0 commit comments