Skip to content

Commit

Permalink
LOG_ERROR_PERIODICALLY() would not log in the first hour after system…
Browse files Browse the repository at this point in the history
… boot.

Since it uses the monotonic clock, the "origin" time is system boot time. So the first time LOG_ERROR_PERIODICALLY() runs, it thinks it last logged at system boot time, and it only logs again if it's been more than an hour since then.

We'll just subtract an hour from the origin. Monotonic time is never negative so this should be sufficient.
  • Loading branch information
kentonv committed May 9, 2023
1 parent 40b7de8 commit 3f39259
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/workerd/util/sentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ inline kj::StringPtr maybeOmitColoFromSentry(uint32_t coloId) {
#define LOG_ERROR_PERIODICALLY(...) \
do { \
static kj::TimePoint KJ_UNIQUE_NAME(lastLogged) = \
kj::origin<kj::TimePoint>(); \
kj::origin<kj::TimePoint>() - 1 * kj::HOURS; \
const auto now = kj::systemCoarseMonotonicClock().now(); \
const auto elapsed = now - KJ_UNIQUE_NAME(lastLogged); \
if (KJ_UNLIKELY(elapsed >= 1 * kj::HOURS)) { \
Expand Down

0 comments on commit 3f39259

Please # to comment.