Skip to content

Commit 98d9540

Browse files
committed
src: use uv_hrtime as tracing timestamp
Override the V8 TracingController to provide uv_hrtime based timestamps. This allows tracing timestamps to be comparable with process.hrtime timestamps. Fixes: #17349 PR-URL: #18196 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
1 parent 51054da commit 98d9540

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

doc/api/tracing.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ node --trace-events-enabled --trace-event-categories v8,node,node.async_hooks se
1919
Running Node.js with tracing enabled will produce log files that can be opened
2020
in the [`chrome://tracing`](https://www.chromium.org/developers/how-tos/trace-event-profiling-tool)
2121
tab of Chrome.
22+
23+
Starting with Node 10.0.0, the tracing system uses the same time source as the
24+
one used by `process.hrtime()` however the trace-event timestamps are expressed
25+
in microseconds, unlike `process.hrtime()` which returns nanoseconds.

src/tracing/agent.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@
88
namespace node {
99
namespace tracing {
1010

11-
using v8::platform::tracing::TracingController;
11+
class TracingController : public v8::platform::tracing::TracingController {
12+
public:
13+
TracingController() : v8::platform::tracing::TracingController() {}
14+
15+
int64_t CurrentTimestampMicroseconds() override {
16+
return uv_hrtime() / 1000;
17+
}
18+
};
1219

1320
class Agent {
1421
public:

0 commit comments

Comments
 (0)