NestJS Profiler
Tutorials

Tutorials

Step-by-step NestJS profiler tutorials - enable collectors for SQL, HTTP, GraphQL, cache and auth, and build your own custom collector and entrypoint types.

These tutorials show how to integrate each profiler collector in a real NestJS application. Each tutorial starts from a concrete use case and includes the full application-side code.

Tutorials are task-oriented walkthroughs. For the exhaustive option reference, peer dependencies and captured fields of each collector, see its package page instead of repeating them here.

Set up the profiler

Install @eleven-labs/nest-profiler and inspect HTTP requests in the built-in profiler UI.

Log capture with context

Wrap your logger so request-scoped logs with structured payloads appear in the Logs tab.

TypeORM query profiling

Capture every SQL query executed by TypeORM and inspect them in the Database panel.

MikroORM query profiling

Capture every SQL query executed by MikroORM and inspect them in the Database panel.

MongoDB query profiling

Capture every Mongoose query and aggregation and inspect them in the MongoDB panel.

Cache profiling

Track cache HIT/MISS/SET/DEL operations and analyse the hit ratio in the Cache panel.

Command profiling

Profile nest-commander CLI commands and inspect their runs in the Command panel at /_profiler.

Auth/Security profiling

Display authenticated user info and JWT claims in the Security panel.

HTTP client profiling

Capture outgoing HTTP requests - with the axios adapter or any client of your own - and inspect them in the HTTP Client panel.

Configuration profiling

Inspect resolved configuration values with sensitive key masking in the Config panel.

DTO validation profiling

Inspect DTO validations - both successful and failed - in the Validator panel.

GraphQL profiling

Profile GraphQL queries and mutations with Apollo, Mercurius, or graphql-yoga, and inspect them in the profiler UI.

Build a custom collector

Create your own profiler panel with a custom EJS template and toolbar badge.

Build a custom entrypoint type

Give a non-HTTP entrypoint its own data shape, list table and detail tab - profiling WebSocket messages end to end.

File-based profile storage

Persist profiles to disk so they survive restarts and can be inspected across debug sessions.

Covered patterns

TutorialNestJS patternPackage
Set up the profilerMiddleware + interceptor + global guard@eleven-labs/nest-profiler
Log capture with contextapp.useLogger proxy + argument parsing@eleven-labs/nest-profiler
TypeORM query profilingDataSource patching + QueryRunner wrap@eleven-labs/nest-profiler-typeorm
MikroORM query profilingLogger.logQuery wrap + CLS context@eleven-labs/nest-profiler-mikro-orm
MongoDB query profilingQuery/Aggregate.exec patch + CLS context@eleven-labs/nest-profiler-mongoose
Cache profilingCACHE_MANAGER proxy + CLS context@eleven-labs/nest-profiler-cache
Command profilingCommandRunner wrap + CommandFactory@eleven-labs/nest-profiler-commander
Auth/Security profilingrequest.user + JWT decode@eleven-labs/nest-profiler-auth
HTTP client profilingHttpProfilerRecorder + bundled axios adapter@eleven-labs/nest-profiler-http
Configuration profilingConfigService internalConfig + registerAs@eleven-labs/nest-profiler-config
DTO validation profilingapp-owned pipe + class-validator / nestjs-zod@eleven-labs/nest-profiler-validator
GraphQL profilingIContextAdapter + GraphQL execution ctx@eleven-labs/nest-profiler-graphql
Build a custom collector@ProfilerCollector + EJS template@eleven-labs/nest-profiler
Build a custom entrypoint typeIContextAdapter + registerEntrypointType@eleven-labs/nest-profiler
File-based profile storagestorageType: 'file' + LRU/TTL eviction@eleven-labs/nest-profiler

Example application

The examples/api directory contains a complete marketplace application demonstrating all collectors working together: an in-memory or SQL catalog (REST + GraphQL), MongoDB-backed reviews publishing RabbitMQ events, an external content API with caching, JWT auth and CLI commands. See the Example application page.

Powered & maintained by

On this page