Skip to content

Commit

Permalink
regression: add tracing instrumentation on LocalBroker (#33750)
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardogarim authored Oct 24, 2024
1 parent ccaa315 commit 349e646
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions packages/core-services/src/LocalBroker.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -17,17 +18,22 @@ export class LocalBroker implements IBroker {
private services = new Set<IServiceClass>();

async call(method: string, data: any): Promise<any> {
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<any> {
Expand Down

0 comments on commit 349e646

Please sign in to comment.