npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

pino-trace

v0.1.0

Published

Trace all async operations performantly with pino the fast logger

Readme

pino-trace

Trace all async operations performantly with pino the fast logger

Build Status

About

pino-trace uses async-tracer to hook into async operations (via the native async_wrap binding) and output logs in an optimal way that's compatible with and supportive of pino's log format.

Supports

Node v4 to v6

Usage

Logger at trace level

By default, pino-trace logs operations at the trace level:

var pino = require('pino')
var trace = require('pino-trace')

var logger = pino({level: 'trace'})

trace(logger)

Tracer at info level

Alternatively, we can keep pino at the info level and tell pino-trace to log at that the info level

var pino = require('pino')
var trace = require('pino-trace')

var logger = pino()

trace(logger, {level: 'info'})

Turning Tracing on Dynamically

pino-trace will respond to changes in log level

var pino = require('pino')
var trace = require('pino-trace')

var logger = pino()

trace(logger)

// some time later:
logger.level = 'trace'
// now ops will be logged
logger.level = 'info'
// ops stop being captured and logged

Child loggers

Child loggers are supported:

var pino = require('pino')
var trace = require('pino-trace')

var logger = pino().child({bound: 'data'})
logger.level = 'trace'
trace(logger) // all trace events will have `bound` field

Shorthand

pino-trace returns the passed in logger instance, allowing for a shorthand:

var logger = require('pino-trace')(require('pino')())

API

require('pino-trace') => (Pino: logger, opts) => logger

Opts

level [default: 'trace'] 'String or Number'

Set the log level at which traced operations are recorded at. If a string, then a relevant pino log level. If a number, then a corresponding pino log level value.

stacks [default: false] Boolean or Number

If true then include an array of call sites in each init log. The stack array takes the following form:

["functionName:fileName:lineNum:colNum"]

If set to a number, (from 1 to Infinity) stacks will also determine the maximum amount of frames to capture for the log (defaults to Infinity if true).

contexts [default: false] Boolean

Supply the operations context in the pre and post logs. The context is an exposed C object that holds state for the async op.

Ecosystem Integration

pino-trace is compatible with express-pino-logger, restify-pino-logger, koa-pino-logger, and rill-pino-logger middleware.

In each case, simply pass the middleware into pino-trace:

var pino = require('express-pino-logger')
var trace = require('pino-trace')

var app = express()

app.use(trace(pino({level: 'trace'})))

Benchmarks

Overhead of using pino-trace is about 25%.

npm run benchmark

With tracing

Running 10s test @ http://localhost:3000
10 connections with 10 pipelining factor

Stat         Avg      Stdev     Max
Latency (ms) 0.23     0.75      37
Req/Sec      33652.37 2340.03   35039
Bytes/Sec    3.74 MB  249.94 kB 3.93 MB

Without tracing

Running 10s test @ http://localhost:3000
10 connections with 10 pipelining factor

Stat         Avg      Stdev     Max
Latency (ms) 0.13     0.42      34
Req/Sec      45682.91 1310.58   46335
Bytes/Sec    5.06 MB  150.72 kB 5.24 MB

Overhead of turning on tracing with async_wrap is around 8%, so the net overhead is 17%, mostly this is the cost of writing to a stream.

Test

npm test
test/index.js ....................................... 61/61
total ............................................... 61/61

  61 passing (445.565ms)

  ok
-----------|----------|----------|----------|----------|----------------|
File       |  % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |
-----------|----------|----------|----------|----------|----------------|
 __root__/ |      100 |      100 |      100 |      100 |                |
  index.js |      100 |      100 |      100 |      100 |                |
-----------|----------|----------|----------|----------|----------------|
All files  |      100 |      100 |      100 |      100 |                |
-----------|----------|----------|----------|----------|----------------|

License

MIT

Acknowledgements

Sponsored by nearForm