Skip to content

Commit

Permalink
src: use uv_hrtime as tracing timestamp
Browse files Browse the repository at this point in the history
Override the V8 TracingController to provide uv_hrtime based
timestamps. This allows tracing timestamps to be comparable with
process.hrtime timestamps.

Fixes: nodejs#17349
PR-URL: nodejs#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>
  • Loading branch information
ofrobots committed Jan 24, 2018
1 parent 51054da commit 98d9540
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions doc/api/tracing.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ node --trace-events-enabled --trace-event-categories v8,node,node.async_hooks se
Running Node.js with tracing enabled will produce log files that can be opened
in the [`chrome://tracing`](https://www.chromium.org/developers/how-tos/trace-event-profiling-tool)
tab of Chrome.

Starting with Node 10.0.0, the tracing system uses the same time source as the
one used by `process.hrtime()` however the trace-event timestamps are expressed
in microseconds, unlike `process.hrtime()` which returns nanoseconds.
9 changes: 8 additions & 1 deletion src/tracing/agent.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@
namespace node {
namespace tracing {

using v8::platform::tracing::TracingController;
class TracingController : public v8::platform::tracing::TracingController {
public:
TracingController() : v8::platform::tracing::TracingController() {}

int64_t CurrentTimestampMicroseconds() override {
return uv_hrtime() / 1000;
}
};

class Agent {
public:
Expand Down

0 comments on commit 98d9540

Please sign in to comment.