Registry / observability / chrome-trace-event

chrome-trace-event

JSON →
library1.0.4jsnpmunverified

The `chrome-trace-event` library provides a programmatic interface for Node.js applications to generate detailed performance logs in Google's Trace Event format. These logs, typically JSON files, can then be loaded and visualized using powerful analysis tools such as `chrome://tracing` in Chrome DevTools or Google's `trace-viewer`. This allows developers to gain deep insights into their application's execution flow, identify bottlenecks, and understand inter-process communication or asynchronous operations. The current stable version is 1.0.4, which was last published over two years ago. Due to its age and lack of recent updates, its release cadence is effectively dormant. Its primary differentiator is its straightforward approach to producing a universally accepted profiling format that integrates directly into established Chrome-based visualization ecosystems.

npm install chrome-trace-event
INSTALL
IMPORT
SIG · CHROME-TRACE-EVENT
C
chrome-trace-event
observabilityjavascriptv1.0.4
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Tracer
import { Tracer } from 'chrome-trace-event';
const Tracer = require('chrome-trace-event').Tracer;
For modern Node.js ESM projects, use named ES module imports. The package ships TypeScript types, supporting this import style.
Tracer (CommonJS)
const Tracer = require('chrome-trace-event').Tracer;
This is the CommonJS import style demonstrated in the package's README, suitable for older Node.js projects or CJS modules.
TraceEvent
import type { TraceEvent } from 'chrome-trace-event';
Import `TraceEvent` for type declarations if you need to work with the raw trace event structure in TypeScript.

This quickstart demonstrates how to initialize the Tracer, record various event types (duration, instant, counter), and write the collected trace data to a JSON file. The file can then be loaded into Chrome DevTools (`chrome://tracing`) for visualization.

import { Tracer } from 'chrome-trace-event'; import * as fs from 'node:fs'; import * as path from 'node:path'; const outPath = path.join(process.cwd(), 'my-trace.json'); const trace = new Tracer({ noStream: true // Collect events in memory until flushed }); // Example: Record a duration event trace.begin('main', 'heavyComputation', { duration: 'long' }); function simulateWork(ms: number) { const start = Date.now(); while (Date.now() - start < ms) { // Busy-wait to simulate CPU-bound work } } trace.instant('main', 'startWork', { message: 'Starting simulated work' }); simulateWork(100); trace.counter('main', 'progress', { value: 25 }); simulateWork(200); trace.counter('main', 'progress', { value: 75 }); simulateWork(150); trace.end('main', 'heavyComputation'); trace.instant('main', 'endWork', { message: 'Finished simulated work' }); const stream = fs.createWriteStream(outPath); trace.pipe(stream); stream.on('finish', () => { console.log(`Trace data written to ${outPath}`); console.log('Open chrome://tracing in your browser and load this file.'); }); trace.flush();
Debug
Known issues
gotchaThe `chrome-trace-event` package has not been updated in over two years, with version 1.0.4 being the latest release. While still functional, this means it may not leverage the latest Node.js features, TypeScript syntax, or address compatibility issues with very recent runtime changes.
fix
Review the package's GitHub repository for forks or community-maintained versions if encountering compatibility issues with modern Node.js environments. Consider wrapping it or using a more actively maintained tracing library if extensive new features are required.
affects: >=1.0.4
gotchaThe documentation and `Usage` examples primarily show CommonJS `require()` syntax. In modern Node.js projects using ES Modules, direct use of `require` will lead to errors.
fix
Always use ES module import syntax (`import { Tracer } from 'chrome-trace-event';`) in ES module contexts. If you must use `require` in an ESM file, you'll need to use `createRequire` from the `module` built-in module.
affects: >=1.0.0
Errors
Common errors & fixes
ReferenceError: require is not defined
Attempting to use `require()` in an ECMAScript Module (ESM) file, which does not natively support CommonJS `require`.
fix
Change your import statement to `import { Tracer } from 'chrome-trace-event';` and ensure your project is configured for ESM (e.g., `"type": "module"` in `package.json` or `.mjs` file extension).
Upgrade
Version history
1.0.4latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
22 hits · last 30 days
node
18
OpenAI (training)
1
Resources
chrome-trace-event — npm install chrome-trace-event · libregistry