NestJS Event Emitter

Learn about instrumenting NestJS event-based services.

The @nestjs/event-emitter module is auto-instrumented in @sentry/nestjs 8.39.0 and up.

The NestJS SDK wraps the @OnEvent decorator automatically to:

  • Create performance traces for event handler executions.
  • Automatically capture any unhandled exceptions that occur in event handlers.
  • Maintain visibility into asynchronous event-driven flows.

When an event handler is executed, a new span is created to track its performance, and any errors are automatically reported to Sentry while preserving the original error behavior.

This instrumentation works transparently with existing NestJS event handlers without requiring any code changes to your application.

Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").