Skip to content

Commit

Permalink
fix(grpc-sdk): admin_grpc_requests_total metric (#372)
Browse files Browse the repository at this point in the history
  • Loading branch information
kon14 authored Oct 7, 2022
1 parent 29b3d87 commit 5af2ada
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion libraries/grpc-sdk/src/routing/RoutingManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export class RoutingManager {
if (Object.keys(this._routeHandlers).length === 0) return;
const modifiedFunctions: {
[name: string]: (call: any, callback: any) => void;
} = wrapFunctionsAsync(this._routeHandlers);
} = wrapFunctionsAsync(this._routeHandlers, this.isAdmin ? 'admin' : 'client');
const protoDescriptions = constructProtoFile(
this._router.moduleName,
Object.values(this._moduleRoutes),
Expand Down
7 changes: 5 additions & 2 deletions libraries/grpc-sdk/src/routing/RoutingUtilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,17 @@ function getFormattedModuleName(moduleName: string) {
return moduleName.replace('-', '_');
}

export function wrapFunctionsAsync(functions: { [name: string]: RequestHandlers }): {
export function wrapFunctionsAsync(
functions: { [name: string]: RequestHandlers },
routerType: 'admin' | 'client',
): {
[name: string]: (call: Indexable, callback?: Indexable) => void;
} {
const modifiedFunctions: {
[name: string]: (call: Indexable, callback?: Indexable) => void;
} = {};
Object.keys(functions).forEach(key => {
modifiedFunctions[key] = wrapRouterGrpcFunction(functions[key], 'client');
modifiedFunctions[key] = wrapRouterGrpcFunction(functions[key], routerType);
});
return modifiedFunctions;
}
Expand Down

0 comments on commit 5af2ada

Please sign in to comment.