Skip to content

Commit

Permalink
feat(server,store): keep track of Sentry metrics about which routes a…
Browse files Browse the repository at this point in the history
…nd jobs are run
  • Loading branch information
dirkdev98 committed May 21, 2024
1 parent b113b6b commit ca1a0a8
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 25 deletions.
12 changes: 3 additions & 9 deletions packages/code-gen/src/generated/structure/validators.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions packages/server/src/middleware/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ export function logMiddleware(app, options) {
}

if (_compasSentryExport) {
if (_compasSentryExport?.metrics?.increment) {
_compasSentryExport.metrics.increment("compas.route.name", 1, {
tags: {
compasRouteName: ctx.event.name ?? "<unmatched>",
},
unit: "none",
});
}

const span = _compasSentryExport.getActiveSpan();
if (span) {
span.setStatus(
Expand Down
3 changes: 2 additions & 1 deletion packages/server/src/middleware/sentry.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export function sentry() {
}

return (ctx, next) => {
if (ctx.method === "OPTIONS" || ctx.method === "HEAD") {
const method = ctx.method.toLowerCase();
if (method === "options" || method === "head") {
return next();
}

Expand Down
6 changes: 3 additions & 3 deletions packages/store/src/generated/database/file.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions packages/store/src/generated/database/job.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions packages/store/src/generated/database/sessionStore.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 4 additions & 6 deletions packages/store/src/generated/database/sessionStoreToken.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions packages/store/src/queue-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,15 @@ function queueWorkerRun(
const [job] = await jobTodoQuery(where, orderBy).exec(sql);

if (!job?.id) {
if (_compasSentryExport?.metrics?.increment) {
_compasSentryExport.metrics.increment("compas.queue.job", 1, {
tags: {
compasQueueJob: "<waiting worker>",
},
unit: "none",
});
}

return {
didHandleJob: false,
};
Expand Down Expand Up @@ -522,6 +531,15 @@ async function queueWorkerExecuteJob(logger, sql, options, job) {
description: job.name,
},
async () => {
if (_compasSentryExport?.metrics?.increment) {
_compasSentryExport.metrics.increment("compas.queue.job", 1, {
tags: {
compasQueueJob: job.name,
},
unit: "none",
});
}

return await exec();
},
);
Expand Down

0 comments on commit ca1a0a8

Please sign in to comment.