Skip to content

Commit

Permalink
Add Sentry.setContext to worker tasks (#268)
Browse files Browse the repository at this point in the history
This will make sentry errors more relevant.

Related issues: #149, #267

Docs: https://docs.sentry.io/platforms/node/enriching-events/context/
  • Loading branch information
macobo authored Mar 22, 2021
1 parent 48f9040 commit cba7420
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/worker/worker.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as Sentry from '@sentry/node'

import { initApp } from '../init'
import { createServer } from '../shared/server'
import { status } from '../shared/status'
Expand Down Expand Up @@ -28,6 +30,8 @@ export const createTaskRunner = (server: PluginsServer): TaskWorker => async ({
const timer = new Date()
let response

Sentry.setContext('task', { task, args })

if (task === 'hello') {
response = `hello ${args[0]}!`
}
Expand Down

0 comments on commit cba7420

Please sign in to comment.