Skip to content

Commit

Permalink
Improve recording
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Jan 5, 2025
1 parent 25b00b1 commit 118eef0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,9 @@ private void timeTransferCacheComputation() {
.forEach(reluctance -> {
RouteRequest routeRequest = new RouteRequest();
routeRequest.withPreferences(b -> b.withWalk(c -> c.withReluctance(reluctance)));
timer.transferCacheTimer.record(() ->
timetableRepository.getTransitLayer().initTransferCacheForRequest(routeRequest)
timer.recordTimer(
"transfer_cache_computation",
() -> timetableRepository.getTransitLayer().initTransferCacheForRequest(routeRequest)
);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ public void globalCount(String meterName, long count) {
}
}

public void recordTimer(String meterName, Runnable runnable) {
if (uploadRegistry != null) {
registry.add(uploadRegistry);
var timer = registry.timer(meterName);
timer.record(runnable);
registry.remove(uploadRegistry);
}
}

/**
* Calculate the total time mean for the given timer. If the timer is not
* found {@link #NOT_AVAILABLE} is returned. This can be the case in unit tests,
Expand Down

0 comments on commit 118eef0

Please sign in to comment.