Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions apps/meteor/app/apps/server/bridges/experimental.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,30 @@ import type { IAppServerOrchestrator } from '@rocket.chat/apps';
import { ExperimentalBridge } from '@rocket.chat/apps-engine/server/bridges';
import { Subscriptions } from '@rocket.chat/models';

import { metrics } from '../../../metrics/server/lib/metrics';

export class AppExperimentalBridge extends ExperimentalBridge {
constructor(private readonly orch: IAppServerOrchestrator) {
super();
}

protected async getUserRoomIds(userId: string, appId: string): Promise<string[] | undefined> {
this.orch.debugLog(`The App ${appId} is getting the room ids for the user: "${userId}"`);
const stopTimer = metrics.appBridgeMethods.startTimer({
bridge: 'experimental',
method: 'getUserRoomIds',
app_id: appId,
});

try {
this.orch.debugLog(`The App ${appId} is getting the room ids for the user: "${userId}"`);

const subscriptions = await Subscriptions.findByUserId(userId, { projection: { rid: 1 } }).toArray();

const subscriptions = await Subscriptions.findByUserId(userId, { projection: { rid: 1 } }).toArray();
const result = subscriptions.map((subscription) => subscription.rid);

return subscriptions.map((subscription) => subscription.rid);
return result;
} finally {
stopTimer();
}
}
}
6 changes: 6 additions & 0 deletions apps/meteor/app/metrics/server/lib/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@ export const metrics = {
name: 'rocketchat_apps_failed',
help: 'total apps that failed to load',
}),
appBridgeMethods: new client.Summary({
name: 'rocketchat_apps_bridge_methods',
help: 'summary of app bridge method calls count and time',
labelNames: ['bridge', 'method', 'app_id'],
percentiles,
}),

// Meteor Facts
meteorFacts: new client.Gauge({
Expand Down
Loading