Skip to content

Commit 0aa152b

Browse files
pbhandar2meta-codesync[bot]
authored andcommitted
Fix double-sampling in event tracking
Summary: `CacheAllocator::recordEvent()` and `BlockCache::recordEvent()` both call `eventTracker->sampleKey()` to gate entry, then call `eventTracker->record()` which internally calls `sampleKey()` again. Fix by switching both call sites from `record()` to `recordWithoutSampling()`, since `sampleKey()` is already called by the caller. This matches the documented pattern in `EventTracker.h`: "If you want one sample call per event then consider using sampleKey + recordWithoutSampling." Reviewed By: rlyerly Differential Revision: D100871776 fbshipit-source-id: 3386c0b30de692a7ae3d2cf3bcd36016a26ab47d
1 parent 014e95d commit 0aa152b

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

cachelib/allocator/CacheAllocator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1865,7 +1865,7 @@ class CacheAllocator : public CacheBase {
18651865
eventInfo.poolId = *params.poolId;
18661866
}
18671867

1868-
eventTracker->record(eventInfo);
1868+
eventTracker->recordWithoutSampling(eventInfo);
18691869
}
18701870
} else if (auto legacyEventTracker = getLegacyEventTracker()) {
18711871
folly::Optional<uint32_t> size =

cachelib/navy/block_cache/BlockCache.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1032,7 +1032,7 @@ void BlockCache::recordEvent(folly::StringPiece key,
10321032
}
10331033
}
10341034

1035-
eventTracker->record(eventInfo);
1035+
eventTracker->recordWithoutSampling(eventInfo);
10361036
} else if (legacyEventTracker_.has_value()) {
10371037
legacyEventTracker_->get().record(event, key, result, size);
10381038
}

0 commit comments

Comments
 (0)