Skip to content

Commit af0854d

Browse files
authored
feat(api-gateway, server-core): Orchestration API telemetry (#6419)
1 parent 800a96b commit af0854d

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

packages/cubejs-api-gateway/src/gateway.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ class ApiGateway {
136136

137137
protected readonly playgroundAuthSecret?: string;
138138

139+
protected readonly event: (name: string, props?: object) => void;
140+
139141
public constructor(
140142
protected readonly apiSecret: string,
141143
protected readonly compilerApi: any,
@@ -166,6 +168,8 @@ class ApiGateway {
166168
this.requestLoggerMiddleware = options.requestLoggerMiddleware || this.requestLogger;
167169
this.contextRejectionMiddleware = options.contextRejectionMiddleware || (async (req, res, next) => next());
168170
this.wsContextAcceptor = options.wsContextAcceptor || (() => ({ accepted: true }));
171+
// eslint-disable-next-line @typescript-eslint/no-empty-function
172+
this.event = options.event || function () {};
169173
}
170174

171175
public initApp(app: ExpressApplication) {
@@ -794,6 +798,9 @@ class ApiGateway {
794798
default:
795799
throw new Error(`The '${query.action}' action type doesn't supported.`);
796800
}
801+
this.event(`pre_aggregations_jobs_${query.action}`, {
802+
source: req.header('source') || 'unknown',
803+
});
797804
response(result, { status: 200 });
798805
} catch (e) {
799806
this.handleError({ e, context, query, res: response, started });

packages/cubejs-api-gateway/src/types/gateway.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ interface ApiGatewayOptions {
7070
*/
7171
checkAuthMiddleware?: CheckAuthMiddlewareFn;
7272
contextToApiScopes?: ContextToApiScopesFn;
73+
event?: (name: string, props?: object) => void;
7374
}
7475

7576
export {

packages/cubejs-server-core/src/core/server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ export class CubejsServerCore {
457457
scheduledRefreshTimeZones: this.options.scheduledRefreshTimeZones,
458458
serverCoreVersion: this.coreServerVersion,
459459
contextToApiScopes: this.options.contextToApiScopes,
460+
event: this.event,
460461
}
461462
));
462463
}

0 commit comments

Comments
 (0)