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

@logtide/express

v0.5.6

Published

LogTide SDK middleware for Express — request tracing and error capture

Readme


Features

  • Automatic request spans for every incoming request
  • Error capture with full request context
  • W3C Trace Context propagation (traceparent in/out)
  • Breadcrumbs for HTTP requests
  • Scope access via req.logtideScope
  • Express 4 and 5 support
  • Full TypeScript support with strict types

Installation

npm install @logtide/express
# or
pnpm add @logtide/express
# or
yarn add @logtide/express

Quick Start

import express from 'express';
import { logtide } from '@logtide/express';

const app = express();

app.use(logtide({
  dsn: 'https://[email protected]',
  // Or use apiUrl + apiKey instead of dsn:
  // apiUrl: 'https://your-instance.com',
  // apiKey: 'lp_your_key',
  service: 'my-express-api',
  environment: 'production',
}));

app.get('/hello', (req, res) => {
  res.json({ message: 'Hello World' });
});

app.listen(3000);

How It Works

The middleware runs on every request and:

  1. Extracts incoming traceparent header (or generates a new trace ID)
  2. Creates a span named after the request (e.g. GET /hello)
  3. Stores scope on the request object (req.logtideScope)
  4. Calls next() to process the request
  5. Finishes the span with ok or error based on response status
  6. Injects traceparent into the response headers
  7. Captures errors for 5xx responses with full context

Accessing the Scope

Use req.logtideScope to access the LogTide scope inside your handlers:

app.get('/users/:id', (req, res) => {
  const scope = req.logtideScope;
  const traceId = req.logtideTraceId;

  // Add custom breadcrumbs
  scope?.addBreadcrumb({
    type: 'query',
    category: 'database',
    message: 'SELECT * FROM users WHERE id = ?',
    timestamp: Date.now(),
  });

  res.json({ id: req.params.id });
});

Configuration

All ClientOptions from @logtide/core are supported:

| Option | Type | Default | Description | |--------|------|---------|-------------| | dsn | string | required | DSN string: https://lp_KEY@host/PROJECT | | service | string | required | Service name for log attribution | | environment | string | — | Environment (e.g. production, staging) | | release | string | — | Release / version identifier | | debug | boolean | false | Enable debug logging | | tracesSampleRate | number | 1.0 | Sample rate for traces (0.0 to 1.0) |

See @logtide/core README for the full list of options.


Error Handling

5xx responses are automatically captured with:

  • HTTP method and URL
  • Request span marked as error
  • Error log with status code

For custom error handling, use Express error middleware:

app.use((err, req, res, next) => {
  const scope = req.logtideScope;
  if (scope) {
    const { hub } = require('@logtide/core');
    hub.getClient()?.captureError(err, {
      'http.method': req.method,
      'http.url': req.originalUrl,
    }, scope);
  }
  res.status(500).json({ error: 'Internal Server Error' });
});

Exports

import { logtide } from '@logtide/express';
import type { LogtideExpressOptions } from '@logtide/express';

License

MIT License - see LICENSE for details.

Links