Skip to content

feat: v2 enhancements — auto instrumentation, HTTP tracing, flamegraph UI, CLI, Chrome export#1

Merged
beingmartinbmc merged 1 commit intomainfrom
feat/v2-enhancements
Mar 8, 2026
Merged

feat: v2 enhancements — auto instrumentation, HTTP tracing, flamegraph UI, CLI, Chrome export#1
beingmartinbmc merged 1 commit intomainfrom
feat/v2-enhancements

Conversation

@beingmartinbmc
Copy link
Copy Markdown
Owner

Summary

Five major features added to node-request-trace:

1. Automatic Middleware Instrumentation

  • Express: Enhanced autoTrack wraps middleware layers with timing
  • Fastify: Lifecycle phase timing (onRequest, preParsing, preValidation, handler, onSend)
  • Koa: trace.instrumentKoa(app) patches app.use() to auto-wrap each middleware

2. HTTP Client Tracing

  • Auto-instruments http.request, http.get, https.request, https.get, globalThis.fetch
  • Records outgoing calls as steps with type: 'http-outgoing'
  • Enable via traceOutgoing: true config or enableHttpTracing() / disableHttpTracing()

3. Timeline / Flamegraph UI

  • Waterfall — bars proportional to step duration (default)
  • Timeline — time-proportional positioning showing concurrency
  • Flamegraph — compact stacked blocks view
  • Chrome Trace export button in detail panel

4. CLI Tool (npx node-request-trace)

  • Commands: stats, recent, slow, inspect, tail, export
  • ANSI colored output with waterfall bars and flamegraph in terminal

5. Chrome Trace Export

  • GET /trace/:id/chrome HTTP endpoint
  • exportChromeTrace() and exportChromeTraceJson() API methods
  • Compatible with chrome://tracing

Testing

  • 178 tests passing
  • 100% coverage (statements, branches, functions, lines)

1. Automatic Middleware Instrumentation
   - Express autoTrack (existing, enhanced)
   - Fastify lifecycle phase timing (onRequest, preParsing, preValidation, handler, onSend)
   - Koa instrumentKoa(app) patches app.use() to auto-wrap middleware

2. HTTP Client Tracing
   - Auto-instrument http.request, http.get, https.request, https.get, fetch
   - Records outgoing calls as steps with type 'http-outgoing'
   - Enable via traceOutgoing config or enableHttpTracing()/disableHttpTracing()

3. Timeline / Flamegraph UI
   - Waterfall view (default) - bars proportional to duration
   - Timeline view - time-proportional positioning
   - Flamegraph view - compact stacked blocks
   - Chrome Trace export button in detail panel

4. CLI Tool (npx node-request-trace)
   - stats, recent, slow, inspect, tail, export commands
   - ANSI colored terminal output with waterfall bars and flamegraph

5. Chrome Trace Export
   - /trace/:id/chrome HTTP endpoint
   - exportChromeTrace() and exportChromeTraceJson() API methods
   - Compatible with chrome://tracing

Tests: 178 passing, 100% coverage across all files
README: fully updated with all new features and examples
@beingmartinbmc beingmartinbmc merged commit f375f5f into main Mar 8, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant