Skip to content

Commit 123a429

Browse files
ohodsonfhanau
authored andcommitted
Add support for counting invocations of now()
Bug: EW-7840 Test: internal
1 parent f35d5a8 commit 123a429

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

src/workerd/io/io-context.c++

+1
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,7 @@ size_t IoContext::getTimeoutCount() {
773773

774774
kj::Date IoContext::now(IncomingRequest& incomingRequest) {
775775
kj::Date adjustedTime = incomingRequest.ioChannelFactory->getTimer().now();
776+
incomingRequest.metrics->clockRead();
776777

777778
KJ_IF_SOME (maybeNextTimeout, timeoutManager->getNextTimeout()) {
778779
// Don't return a time beyond when the next setTimeout() callback is intended to run. This

src/workerd/io/observer.h

+2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ class RequestObserver: public kj::Refcounted {
7070
virtual void finishedWaitUntilTask() {}
7171

7272
virtual void setFailedOpen(bool value) {}
73+
74+
virtual uint64_t clockRead() { return 0; }
7375
};
7476

7577
class IsolateObserver: public kj::AtomicRefcounted, public jsg::IsolateObserver {

0 commit comments

Comments
 (0)