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

drtrace

v0.5.0

Published

DrTrace JavaScript/TypeScript client

Readme

DrTrace JavaScript Client

DrTrace JavaScript/TypeScript client for distributed tracing-style logging and analysis.

Installation

npm install drtrace

Quick Start

Interactive Project Initialization

npx drtrace init

This runs an interactive setup wizard that creates the _drtrace/ configuration folder with:

  • Main configuration file (config.json)
  • Environment-specific overrides
  • Environment variables template (.env.example)
  • Configuration guide (README.md)
  • Default agent specification

Node.js Usage

import { DrTrace } from 'drtrace';

// Initialize from _drtrace/config.json automatically
const client = DrTrace.init();

// Or override specific options
// const client = DrTrace.init({
//   applicationId: 'my-app',
//   daemonUrl: 'http://localhost:8001',
//   batchSize: 50,
//   flushIntervalMs: 1000,
//   maxRetries: 3,
//   maxQueueSize: 10000,
// });

// Attach to console
client.attachToConsole();

// Logs are now automatically sent to the DrTrace daemon
console.log('This is captured by DrTrace');
console.error('Errors are also captured');

Browser Usage (React, Vue, etc.)

In browser environments, you must provide applicationId and daemonUrl explicitly since the browser cannot read config files from the filesystem.

import { DrTrace } from 'drtrace';  // Auto-selects browser entry point

// Browser requires explicit options (no config file loading)
const client = DrTrace.init({
  applicationId: 'my-react-app',
  daemonUrl: 'http://localhost:8001',
  moduleName: 'frontend',  // Optional: helps identify log source
  batchSize: 50,
  flushIntervalMs: 1000,
});

// Attach to console
client.attachToConsole();

// Objects are serialized properly
console.log({ user: 'john', action: 'login' });  // Logs as JSON
console.error('Something went wrong', new Error('Details'));

Important for Browser:

  • applicationId is required - throws error if missing
  • daemonUrl is required - throws error if missing
  • CORS must be enabled on the daemon (enabled by default)
  • Objects and errors are automatically serialized to JSON

CORS Configuration

The DrTrace daemon allows all origins by default. To restrict origins:

# Allow specific origins
export DRTRACE_CORS_ORIGINS="http://localhost:3000,https://myapp.com"

# Start daemon
uvicorn drtrace_service.api:app --host localhost --port 8001

Starting the DrTrace Daemon

Important: The DrTrace daemon must be running before your application can send logs.

Option A: Docker Compose (Recommended)

# From the DrTrace repository root
docker-compose up -d

# Verify it's running
curl http://localhost:8001/status

Option B: Native Python Daemon

# Set database URL (if using PostgreSQL)
export DRTRACE_DATABASE_URL="postgresql://postgres:postgres@localhost:5432/drtrace"

# Start the daemon
uvicorn drtrace_service.api:app --host localhost --port 8001

# In another terminal, verify it's running
python -m drtrace_service status

Note: The daemon runs on http://localhost:8001 by default. Make sure this matches your daemonUrl in the config.

Configuration

Configuration is managed via _drtrace/config.json created during npx drtrace init.

Basic Config Structure

{
  "project": {
    "name": "my-app",
    "language": "javascript"
  },
  "drtrace": {
    "applicationId": "my-app-123",
    "daemonUrl": "http://localhost:8001",
    "enabled": true,
    "logLevel": "info",
    "batchSize": 50,
    "flushIntervalMs": 1000,
    "maxRetries": 3,
    "maxQueueSize": 10000,
    "timeoutMs": 5000,
    "retentionDays": 7
  },
  "agent": {
    "enabled": false,
    "framework": "bmad"
  }
}

Environment Variables

Override config via environment variables:

  • DRTRACE_APPLICATION_ID - Application identifier
  • DRTRACE_DAEMON_URL - Daemon URL
  • DRTRACE_ENABLED - Enable/disable DrTrace
  • DRTRACE_LOG_LEVEL - Log level (debug, info, warn, error)

Development

Setup

npm install
npm run build

Testing

npm test
npm run test:watch

Building

npm run build

Linting & Formatting

npm run lint
npm run format

API Reference

new DrTrace(options)

Create a new DrTrace client instance.

Options:

  • applicationId (required) - Unique application identifier
  • daemonUrl (required in browser, optional in Node.js) - DrTrace daemon URL (default: http://localhost:8001)
  • moduleName (optional) - Module/component name for log grouping (default: 'default')
  • enabled (optional) - Enable/disable DrTrace (default: true)
  • batchSize (optional) - Batch size for log batching (default: 50)
  • flushIntervalMs (optional) - Flush interval in milliseconds (default: 1000)
  • maxRetries (optional) - Retry attempts for failed sends with exponential backoff (default: 3)
  • maxQueueSize (optional) - Maximum queued log entries before oldest entries are dropped (default: 10000)

client.attachToConsole()

Attach DrTrace to Node.js console for automatic log capture.

client.log(level, message, metadata?)

Send a log entry to DrTrace.

Parameters:

  • level - Log level: 'debug', 'info', 'warn', 'error'
  • message - Log message
  • metadata (optional) - Additional context as object

License

MIT