Closed joaosilva0345 closed 1 month ago
I arrived at the following solution, but I don't know if it is correct:
import { inject } from '@adonisjs/core'
import { Job } from '@rlanz/bull-queue'
import { Sentry } from '@rlanz/sentry'
@inject()
export default class TestJob extends Job {
constructor(private sentry: Sentry) {
super()
}
static get $$filepath() {
return import.meta.url
}
async handle() {
console.log(this.sentry.getUser()) // test sentry
return
}
async rescue() {}
}
Is the only way to access the sentry out of context through injection?
Hey @joaosilva0345! 👋🏻
Yes, it is the way!
Thank you.
Hi, everyone!
I am using Sentry integrated with the IoC Container and HttpContext in my AdonisJS application. The installation and configuration of Sentry are working perfectly to capture errors within the HTTP request context. However, I have no idea how to integrate Sentry outside of this context, specifically in asynchronous methods and jobs.
Below is an example of a job I am using:
Can anyone guide me on how to access the Sentry service outside the request context, in asynchronous functions and jobs?
Thank you!