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

@pocket-so/tracing

v1.0.1

Published

Internal tracing helpers for Hono backends (Node/Bun/Cloudflare Workers).

Readme

tracing

Internal tracing helpers for Hono backends (Node/Bun/Cloudflare Workers).

Display of the trace and spans in Axiom

Install

bun add @pocket/tracing

Ignore Routes

Skip tracing for specific paths. Use ignore.list for the paths and ignore.exact (default true) for matching:

  • exact: true (default) – only paths in the list are ignored (exact match).
  • exact: false – each list entry also matches nested subpaths (e.g. /openapi ignores /openapi, /openapi/spec, /openapi/docs).
app.use(
  tracing({
    loggers: [],
    ignore: { exact: true, list: ['/openapi', '/ready'] },
  }),
);

// Ignore /openapi and all nested paths
app.use(
  tracing({
    loggers: [],
    ignore: { exact: false, list: ['/openapi'] },
  }),
);

Error handling

You can pass an optional onError callback to be notified when a batch commit fails (e.g. export to Axiom/Sentry fails). Use it for logging, metrics, or custom alerting. The callback receives the error; it is best-effort and does not affect request handling.

app.use(
  tracing({
    loggers: [getAxiomLogger(config)],
    onError: (err) => {
      console.error('Tracing export failed', err);
      // or: metrics.increment('tracing.export.failed');
    },
  }),
);

Logger singleton and testing

Each logger is exposed as a singleton via getXxxLogger(config) (e.g. getAxiomLogger, getSentryLogger, getConsoleLogger, getTimescaleLogger). The first config wins: the first call to getXxxLogger(config) creates the instance and caches it; later calls with different config return the same instance and ignore the new config. This is intentional for production (single process, one config).

For tests or when you need multiple instances or a fresh instance per run, use the factory instead:

  • createAxiomLogger(config) – new Axiom logger instance
  • createSentryLogger(config) – new Sentry logger instance
  • createConsoleLogger(config) – new Console logger instance
  • createTimescaleLogger(config) – new Timescale logger instance

Each factory returns a new Logger every time and does not touch the singleton. Example:

import { createConsoleLogger } from '@pocket/tracing/loggers/console';

const testLogger = createConsoleLogger({ metadata: { service: 'test', version: '0', environment: 'test' } });
// testLogger is a new instance; getConsoleLogger() singleton is unchanged

Build and runtimes

The package is built with a browser platform target (single bundle). Middleware and loggers (Axiom, Sentry, Console) are suitable for Node, Bun, and Cloudflare Workers. The Timescale logger and the @pocket/tracing/timescale/db export are server-only: they depend on postgres and Drizzle and must not be used in browser environments. Use them only in Node, Bun, or Workers backends.

Graceful Shutdown

To ensure all pending traces are flushed on shutdown, get the tracer with getTracer() and call dispose():

import { getTracer, tracing } from '@pocket/tracing/middleware';

app.use(tracing({ loggers: [/* ... */] }));

// For Node.js / Bun
process.on('SIGTERM', async () => {
  const tracer = getTracer();
  if (tracer) await tracer.dispose();
  process.exit(0);
});

// For Cloudflare Workers
export default {
  async fetch(request, env, ctx) {
    const response = await app.fetch(request, env, ctx);
    const tracer = getTracer();
    if (tracer) ctx.waitUntil(tracer.dispose());
    return response;
  },
};