diff --git a/packages/core-services/src/LocalBroker.ts b/packages/core-services/src/LocalBroker.ts index 451ced1cf39f..28aa0bc4fc80 100644 --- a/packages/core-services/src/LocalBroker.ts +++ b/packages/core-services/src/LocalBroker.ts @@ -1,6 +1,7 @@ import { EventEmitter } from 'events'; import { InstanceStatus } from '@rocket.chat/models'; +import { injectCurrentContext, tracerActiveSpan } from '@rocket.chat/tracing'; import { asyncLocalStorage } from '.'; import type { EventSignatures } from './events/Events'; @@ -17,17 +18,22 @@ export class LocalBroker implements IBroker { private services = new Set(); async call(method: string, data: any): Promise { - const result = await asyncLocalStorage.run( - { - id: 'ctx.id', - nodeID: 'ctx.nodeID', - requestID: 'ctx.requestID', - broker: this, + return tracerActiveSpan( + `action ${method}`, + {}, + () => { + return asyncLocalStorage.run( + { + id: 'ctx.id', + nodeID: 'ctx.nodeID', + requestID: 'ctx.requestID', + broker: this, + }, + (): any => this.methods.get(method)?.(...data), + ); }, - (): any => this.methods.get(method)?.(...data), + injectCurrentContext(), ); - - return result; } async waitAndCall(method: string, data: any): Promise {