Skip to content

CorrelationDecoratorOptions

Defined in: decorators/with-correlation.decorator.ts:24

Options for the WithCorrelation decorator.

optional extract?: CorrelationExtractor

Defined in: decorators/with-correlation.decorator.ts:52

Custom extractor function. Receives all method arguments. Takes precedence over path.

// RabbitMQ
extract: (data, ctx) => ctx.getMessage().properties.correlationId
// Kafka
extract: (data, ctx) =>
ctx.getMessage().headers?.['x-correlation-id']?.toString()

optional logger?: LoggerService

Defined in: decorators/with-correlation.decorator.ts:94

Custom logger instance to use instead of the built-in NestJS Logger.

Accepts any object that implements LoggerService (e.g. a Pino or Winston adapter).

@WithCorrelation({ logger: myPinoLogger })
async handleJob(job: Job) { ... }

optional logLevel?: "verbose" | "debug" | "log" | "warn" | "error" | "fatal" | "none"

Defined in: decorators/with-correlation.decorator.ts:80

Log level for the start of the method execution.

  • Any NestJS LogLevel value routes to the corresponding Logger method ('log', 'debug', 'verbose', 'warn', 'error').
  • 'none' suppresses the log message entirely.

When using nestjs-pino, NestJS levels map to pino levels as follows: 'verbose' → trace, 'debug' → debug, 'log' → info, 'warn' → warn, 'error' → error, 'fatal' → fatal. To see 'verbose' logs, set level: 'trace' in LoggerModule.forRoot.

'debug'
// Uses default 'debug' level
@WithCorrelation()
// Log at 'verbose' level
@WithCorrelation({ logLevel: 'verbose' })
// Suppress the log message
@WithCorrelation({ logLevel: 'none' })

optional path?: string

Defined in: decorators/with-correlation.decorator.ts:36

Property path (dot-notation) to the correlation ID in the first argument.

  • For Bull: 'data.correlationId' (default)
  • For a flat object: 'correlationId'
  • For deeply nested: 'metadata.tracing.correlationId'

Ignored when extract is provided.

'data.correlationId'