NestJS Profiler

Introduction

An open-source NestJS profiler inspired by Symfony's Web Profiler - inspect SQL, HTTP, GraphQL, cache, auth and custom spans to debug and optimize performance.

@eleven-labs/nest-profiler is a Symfony Web Profiler-inspired toolkit for NestJS applications. Every profiled execution - an HTTP request, a GraphQL operation, or a CLI command - receives a unique token, and a rich panel UI at /_profiler lets you inspect request data, logs, exceptions, performance spans, database queries, and 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.

Packages

PackagePanelWhat it captures
@eleven-labs/nest-profilerCoreRequest, response, logs, exceptions, performance spans
@eleven-labs/nest-profiler-typeormDatabaseSQL queries with type, duration, slow-query highlighting
@eleven-labs/nest-profiler-mikro-ormDatabaseSQL queries with type, duration, slow-query highlighting (MikroORM)
@eleven-labs/nest-profiler-mongooseMongoDBMongoose queries & aggregations: collection, operation, duration, result count
@eleven-labs/nest-profiler-httpHTTP ClientOutgoing calls from any client (axios, fetch, your own): method, URL, status, duration, phase timings
@eleven-labs/nest-profiler-cacheCacheGET_HIT / GET_MISS / SET / DEL with hit-ratio badge
@eleven-labs/nest-profiler-commanderCommandnest-commander CLI runs: name, arguments, options, outcome
@eleven-labs/nest-profiler-authSecurityrequest.user, JWT claims, roles - sensitive fields masked
@eleven-labs/nest-profiler-configConfigConfigService snapshot with secret masking
@eleven-labs/nest-profiler-routesDiscoverThe routing table of each transport, discovered at startup: route, handler, guards, inputs
@eleven-labs/nest-profiler-validatorValidatorDTO validation results - property violations with constraint names
@eleven-labs/nest-profiler-graphqlGraphQLGraphQL queries/mutations: operation type, name, query, variables
@eleven-labs/nest-profiler-rabbitmqRabbitMQConsumed @RabbitSubscribe messages, and published ones: exchange, routing key, payload
@eleven-labs/nest-profiler-event-emitterEvents@nestjs/event-emitter emissions and each @OnEvent handler execution

Key features

  • Floating toolbar - injected into HTML responses with per-collector badges (query count, hit ratio, violation count, …)
  • Unified execution trace - the entrypoint, framework phases, queries, outgoing calls and your own tracer.span() on one waterfall, nested by causality
  • Performance tags - a rule engine flags slow queries, N+1, chatty endpoints, large payloads and zero-row writes, and makes them filterable on the list page
  • Extensible collectors - implement IProfilerCollector to add your own panel with a custom EJS template and toolbar badge
  • Three storage backends - in-memory LRU (default), file-based persistence that survives restarts, or a first-party SQLite adapter that filters and paginates in the database
  • Request sampling & path filtering - sampleRate and ignorePaths to control overhead in busy environments
  • Module-per-collector pattern - each optional package is imported in the feature module it instruments, not in the root module
  • GraphQL support - profiles queries and mutations with a GQL badge, operation type/name, and syntax-highlighted query via @eleven-labs/nest-profiler-graphql; compatible with Apollo, Mercurius, and graphql-yoga
  • CLI command profiling - profiles nest-commander commands with a CLI badge in a dedicated Command panel via @eleven-labs/nest-profiler-commander; with file storage the command profiles show up next to HTTP requests at /_profiler

Versioning and stability

Every package follows Semantic Versioning. The public API is what each package exports from its entry point (plus documented subpaths such as @eleven-labs/nest-profiler/sqlite) — breaking changes to it only ship in a major version. Packages are versioned and published together with Changesets.

Two things that are not obvious follow from that:

  • The template contract is public. A custom collector renders its panel from an EJS template, so the design tokens, utility classes and EJS helpers in the Template reference are part of the API and stay stable within a major. The rendered markup of the built-in panels is not — it changes whenever the UI does.
  • Internal plumbing is not exported. The entry point deliberately exposes only what a host application or a collector package needs. Helpers the profiler uses on itself — the list-page pagination, the in-memory query engine, option resolvers — are kept out of it precisely so they can be reworked in a minor release.

Development only

The profiler is designed for development environments. Disable it in production to avoid exposing internal request data — gate it with ConditionalModule.registerWhen. See Getting started.

Powered & maintained by

On this page