NestJS Profiler
API Reference

nest-profiler-mikro-orm

Types and API of the MikroORM query collector.

MikroOrmCollectorModuleOptions

Options passed to MikroOrmCollectorModule.forRoot().

Prop

Type

QueryEntry

One entry per SQL query executed during a request. The SQL collector types are shared with the other SQL ORM collectors and re-exported from this package.

Prop

Type

QueryType

type QueryType = 'SELECT' | 'INSERT' | 'UPDATE' | 'DELETE' | 'OTHER';

Detected from the first keyword of the SQL string.

Public exports

import { MikroOrmCollectorModule } from '@eleven-labs/nest-profiler-mikro-orm';
import { MikroOrmCollector } from '@eleven-labs/nest-profiler-mikro-orm';
import { MikroOrmSchemaCollectorModule } from '@eleven-labs/nest-profiler-mikro-orm';
import { MikroOrmSchemaCollector } from '@eleven-labs/nest-profiler-mikro-orm';

import type {
  MikroOrmCollectorModuleOptions,
  MikroOrmCollectorModuleAsyncOptions,
  MikroOrmSchemaCollectorModuleOptions,
  MikroOrmSchemaCollectorModuleAsyncOptions,
  QueryEntry,
  QueryType,
} from '@eleven-labs/nest-profiler-mikro-orm';

Setup

profiling/profiling.module.ts
// In the dev-only profiling bundle's imports:
MikroOrmCollectorModule.forRoot({
  slowThreshold: 50, // ms — queries at/above this are tagged 'slow'
});

Prerequisite: MikroOrmModule.forRoot() must be registered in the application (provides the MikroORM instance whose logger the collector wraps). The collector resolves it by token, so it needs no wiring in the module that uses MikroORM; pass connectionName for a named context.

ProfilingModule is the dev-only bundle loaded by main-dev.ts — see Enabling and disabling the profiler. If the profiler is installed as a production dependency behind the runtime gate, wrap the same call in ConditionalModule.registerWhen(..., isProfilerEnabled).

Async setup

Drive the options from ConfigService (or any provider) with forRootAsync(), registered in the same bundle. It resolves option values only — for the enabled flag and when to prefer forRoot, see Enabling and disabling the profiler.

import { ConfigService } from '@nestjs/config';
import { MikroOrmCollectorModule } from '@eleven-labs/nest-profiler-mikro-orm';

MikroOrmCollectorModule.forRootAsync({
  inject: [ConfigService],
  useFactory: (config: ConfigService) => ({
    slowThreshold: config.get<number>('PROFILER_SLOW_QUERY_MS') ?? 50,
  }),
});
Powered & maintained by

On this page