Skip to content

Commit 939e25a

Browse files
committed
fix(serverless-aws): cubejsProcess agent doesn't collect all events after process has been finished
1 parent c731356 commit 939e25a

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

packages/cubejs-server-core/core/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ class CubejsServerCore {
323323
initAgent() {
324324
if (process.env.CUBEJS_AGENT_ENDPOINT_URL) {
325325
const oldLogger = this.logger;
326+
this.preAgentLogger = oldLogger;
326327
this.logger = (msg, params) => {
327328
oldLogger(msg, params);
328329
agentCollect(
@@ -337,6 +338,16 @@ class CubejsServerCore {
337338
}
338339
}
339340

341+
async flushAgent() {
342+
if (process.env.CUBEJS_AGENT_ENDPOINT_URL) {
343+
await agentCollect(
344+
{ msg: 'Flush Agent' },
345+
process.env.CUBEJS_AGENT_ENDPOINT_URL,
346+
this.preAgentLogger
347+
);
348+
}
349+
}
350+
340351
static create(options) {
341352
return new CubejsServerCore(options);
342353
}

packages/cubejs-serverless-aws/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class AWSHandlers extends Handlers {
2929
const message = JSON.parse(record.Sns.Message);
3030
await this.processMessage(message);
3131
}));
32+
await this.serverCore.flushAgent();
3233
} else {
3334
this.serverCore.logger('Invalid Lambda Process Message', {
3435
warning: `Event doesn't contain Records field. Skipping.`,

0 commit comments

Comments
 (0)