Skip to content

About

A Symfony Web Profiler-inspired toolkit for NestJS — profile every request with a rich panel UI. Powered & maintained by Eleven Labs.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

18 stars

Watchers

0 watching

Forks

Latest commit

 

History

360 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nest-profiler

Powered & maintained by Eleven Labs

Powered & maintained by Eleven Labs

CI Quality Coverage License: MIT

Documentation Node >= 22 Built with NestJS TypeScript strict Code style: Prettier

Conventional Commits Dependabot enabled PRs welcome

A Symfony Web Profiler-inspired toolkit for NestJS applications. Each profiled execution receives a unique token, and a rich panel UI at /_profiler lets you inspect request data, logs, exceptions, performance spans, and much more — in real time.

The ecosystem is built around an extensible collector architecture: the core package provides the profiler engine, storage, and UI, while optional sub-packages each add a dedicated panel as a self-contained NestJS module.

Profiler UI — the sidebar of views and the HTTP list with its filters

Packages

Each package is a self-contained NestJS module with its own README:

Full guides and API reference live on the documentation site (pnpm docs:dev, then http://localhost:3002).

Panels at a glance

Database panel HTTP Client panel Cache panel
Database (TypeORM) HTTP Client (Axios) Cache
Security panel Validator panel Performance panel
Security (JWT/Auth) Validator (class-validator) Performance (duration, CPU, memory, spans)
RabbitMQ panel MongoDB panel Command panel
RabbitMQ (@RabbitSubscribe) MongoDB (Mongoose) Command (nest-commander)
GraphQL panel Config panel Discover panel
GraphQL (Apollo/Mercurius/graphql-yoga) Config (ConfigService) Discover (REST/GraphQL/RabbitMQ/CLI)
Runtime view Schemas view
Runtime (memory, CPU, event loop, GC) Schemas (TypeORM/MikroORM/Mongoose)

Quickstart

Requirements: Node.js 22+, pnpm 10+

pnpm install        # install dependencies
pnpm build          # build all packages
pnpm test:cov       # run the test suite with coverage
pnpm docs:dev       # serve the documentation site at http://localhost:3002

To try the profiler against a real app, start the databases and the demo API, then open http://localhost:3000/_profiler:

pnpm docker:up      # Postgres + MongoDB + RabbitMQ (runs in the background)
pnpm example:dev

Installation

Packages are published to the public npm registry, no authentication required. The profiler is a development tool: install it as a dev dependency, so production never installs it:

pnpm add -D @eleven-labs/nest-profiler nestjs-cls

Bundle it — with every collector you add — in one module, and load that module from a dev-only entrypoint (main-dev.ts booting an AppDevModule that imports AppModule and ProfilingModule); production keeps running main.ts, untouched:

import { ProfilerModule } from '@eleven-labs/nest-profiler';
import { TypeOrmCollectorModule } from '@eleven-labs/nest-profiler-typeorm';

@Module({
  imports: [
    ProfilerModule.forRoot({ isGlobal: true }),
    TypeOrmCollectorModule.forRoot({ slowThreshold: 50 }),
  ],
})
export class ProfilingModule {}

The Getting started guide walks through the dev entrypoint and the build setup. Does your production code call the profiler — a service injecting TracerService for custom spans, say? Then install it as a regular dependency and gate it with ConditionalModule instead.

Agent skills

Prefer to have your coding agent do the wiring? Installable agent skills teach Claude Code, Cursor, Codex and others how to set up the profiler in your own app — introspecting the project, choosing an enable strategy, and adding the collectors that match your stack:

npx skills add eleven-labs/nest-profiler

Then ask your agent to "set up nest-profiler in this app". See skills/ for the full list.

Repository Layout

A pnpm + Turbo monorepo. Publishable packages live under packages/; everything else supports them.

packages/
  nest-profiler/            core profiler engine, storage, and UI
  nest-profiler-*/          optional collectors (typeorm, mikro-orm, mongoose, http, cache, auth, config, routes, validator, graphql, commander, rabbitmq, event-emitter)
  configs/                  shared @repo/* tooling presets (eslint, jest, prettier, typescript)
examples/
  api/                      NestJS demo app with all collectors enabled
docs/                       Fumadocs documentation site
skills/                     installable agent skills for consumers (npx skills)
scripts/                    repository automation and release helpers

Architecture

The profiler is a thin pipeline wired into the standard NestJS request lifecycle, designed so that collectors stay decoupled from the core and disabling the profiler costs almost nothing.

Two layers: active and inert

The profiler has two layers:

  • Active — mounts the middleware, the global interceptor, the /_profiler controller, the collector registry and storage.
  • Inert — registers only TracerService, with none of its optional dependencies provided, so application code that injects it directly (span(), captureError(), currentToken()) keeps working with zero overhead. There is no separate no-op class: every method of the service is already documented as a no-op outside a profiled execution.

The recommended way to toggle the profiler is ConditionalModule.registerWhen on the active module — it is never loaded when profiling is off. Log capture keeps working regardless: createProfilerLogger is DI-free and a transparent pass-through when off. Only if application code injects TracerService directly do you add ProfilerNoopModule as the off-path fallback (the inert layer above). Turn the profiler on in development and off in production. A top-level enabled flag is also supported as an alternative, documented once in the Configuration guide.

Request lifecycle (HTTP)

request
   │
   ▼
ProfilerMiddleware ── creates a Profile (unique token), stores it in the
   │                   request-scoped CLS context (nestjs-cls)
   ▼
route handler ──────── your code; collectors append entries into the active
   │                   Profile via CLS (SQL queries, HTTP calls, cache ops…)
   ▼
ProfilerInterceptor ── finalizes timing, runs CollectorRegistry.collectAll(),
   │                   lets context adapters enrich the Profile, persists it,
   │                   and injects the toolbar into HTML responses
   ▼
ProfilerStorageService → storage adapter (memory, file, or SQLite)
   │
   ▼
ProfilerController ─── serves the UI at /_profiler (list / detail / data),
                       protected by ProfilerGuard

The shared CLS context (nestjs-cls) is the backbone: the middleware puts the Profile there, and everything downstream — collectors, the logger adapter, TracerService — reads it back without threading the profile through method signatures.

Collectors

Each optional @eleven-labs/nest-profiler-* package is a self-contained NestJS module that does two things:

  1. Patches its host library (the TypeORM driver, the MikroORM logger, axios interceptors, the cache manager, ValidationPipe…) to append entries to the active profile. Patches are idempotent (__profilerPatched) so re-init never double-instruments.
  2. Exposes a panel via a provider annotated with @ProfilerCollector(). The CollectorRegistry auto-discovers these through Nest's DiscoveryService — no manual registration — and calls each collect() to build its panel data.

This is the extension seam: a custom collector is just a provider implementing IProfilerCollector. See Custom collectors.

Non-HTTP protocols

Protocols other than HTTP (GraphQL, gRPC, WebSockets…) are supported through IContextAdapter: an adapter recovers and enriches the profile for its context type, and the interceptor delegates to it automatically once it is registered from your module's onModuleInit via ProfilerCoreService.registerContextAdapter(). See Custom protocol adapters.

Common Commands

Run a task across every package via Turbo:

pnpm lint           # eslint
pnpm typecheck      # tsc --noEmit
pnpm test           # run unit tests
pnpm test:cov       # run tests with coverage (enforces the 90% threshold)
pnpm build          # build all packages
pnpm docs:dev       # serve the docs site
pnpm docker:up      # start Postgres + MongoDB + RabbitMQ for the example (docker:down to stop)
pnpm attw           # check published type resolution (Are the Types Wrong?)
pnpm changeset      # record a version bump

Target a single package with --filter:

pnpm --filter @eleven-labs/nest-profiler test:cov
pnpm --filter @eleven-labs/nest-profiler-typeorm build

Publishing

Packages are versioned with Changesets and released from CI to the public npm registry. The versioning policy, the stable release flow, and the alpha/beta prerelease runbook live in MAINTAINERS.md.

About

A Symfony Web Profiler-inspired toolkit for NestJS — profile every request with a rich panel UI. Powered & maintained by Eleven Labs.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

18 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages