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

@codephil/logging-middleware-ddog

v1.0.1

Published

Express middleware for structured logging to Datadog with pretty console output

Readme

@codephil/logging-middleware-ddog

Express middleware for structured logging to Datadog with pretty console output. Sends logs directly to Datadog's HTTP intake API without requiring the Datadog Agent.

Features

  • 🚀 Direct logging to Datadog via HTTP API
  • 💅 Pretty console output for local development
  • 📊 Automatic HTTP request/response logging
  • ⚡ Performance monitoring with memory usage
  • 🎯 TypeScript type definitions included
  • 🔄 Express middleware compatible

Installation

npm install @codephil/logging-middleware-ddog

Usage

const express = require('express');
const { datadogMiddleware } = require('@codephil/logging-middleware-ddog');

const app = express();

// Initialize the middleware
app.use(datadogMiddleware({
  serviceName: 'your-service-name',    // Optional if set in env
  apiKey: 'your-datadog-api-key',      // Optional if set in env
  nodeEnv: 'development',              // Optional if set in env
  warnThreshold: 1000,                 // Response time warning threshold (ms)
  errorThreshold: 3000                 // Response time error threshold (ms)
}));

// Use the logger in your routes
app.get('/api/users', (req, res) => {
  req.logger.info('Fetching users', { 
    additional: 'context',
    userId: req.user?.id 
  });
  // ... your route logic
});

Environment Variables

The middleware will look for these environment variables if not provided in options:

  • DD_API_KEY: Your Datadog API key
  • SERVICE_NAME: Your service name
  • NODE_ENV: Environment (development, production, etc.)

Options

interface DatadogOptions {
  apiKey?: string;         // Datadog API key
  serviceName?: string;    // Service name for Datadog
  nodeEnv?: string;        // Environment (development, production, etc.)
  logLevel?: string;       // Winston log level
  warnThreshold?: number;  // Response time warning threshold in ms (default: 1000)
  errorThreshold?: number; // Response time error threshold in ms (default: 3000)
}

Console Output

The middleware provides pretty console output for local development:

12:34:56 ℹ️  info: GET /api/users
  → GET /api/users
  ← 200 (45ms)
  ⚡ Performance: 45ms | Memory: 2.5MB

12:34:57 ⚠️  warn: Slow request detected
  → GET /api/tasks
  ← 200 (1250ms)
  ⚡ Performance: 1250ms | Memory: 5.8MB

Status codes are color-coded:

  • 2xx: Green (success)
  • 3xx: Cyan (redirect)
  • 4xx: Yellow (client error)
  • 5xx: Red (server error)

Performance metrics are automatically tracked:

  • Response time warnings when exceeding thresholds
  • Memory usage per request
  • Color-coded performance indicators

Datadog Integration

Logs are sent directly to Datadog's HTTP intake API with the following structure:

{
  message: "HTTP Request Completed",
  level: "info",
  ddsource: "nodejs",
  service: "your-service-name",
  http: {
    method: "GET",
    url: "/api/users",
    status_code: 200,
    response_time_ms: 45
  },
  performance: {
    responseTime: 45,
    memoryUsed: 2621440,  // in bytes
    route: "/api/users"
  },
  // ... additional context
}