diff --git a/docs/platforms/javascript/guides/nestjs/features/event-emitter.mdx b/docs/platforms/javascript/guides/nestjs/features/event-emitter.mdx index 8613f849cc76e6..def20ffa2c0249 100644 --- a/docs/platforms/javascript/guides/nestjs/features/event-emitter.mdx +++ b/docs/platforms/javascript/guides/nestjs/features/event-emitter.mdx @@ -15,4 +15,26 @@ The NestJS SDK wraps the `@OnEvent` decorator automatically to: 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. + + Annotating one function with multiple `@OnEvent` decorators is not recommended, as NestJS provides no way for us to determine the triggering event. Therefore, the resulting span name will include all decorated event names. + + Instead, use one decorator per event name and handle any shared logic through a separate function. + + ```typescript + @OnEvent('event.A') + function myHandlerA(payload: any) { + commonHandler(payload) + } + + @OnEvent('event.B') + function myHandlerB(payload: any) { + commonHandler(payload) + } + + function commonHandler(payload: any) { + // handle stuff + } + ``` + + This instrumentation works transparently with existing NestJS event handlers without requiring any code changes to your application.