Allow user to hook into Breadcrumb in SentryInstrumentation
Problem Statement
I want to add more data into the breadcrumbs generated by SentryInstrumentation,. As a use case, I want to add any parameter named id when resolving any field: user(id: "..."). I could use context data, but with nesting it will not work. Example breadcrumb from sentry.io:
{
field: createXyz,
object_type: Mutation,
path: /createXyz,
type: createXyzPayload
...hook for more data
}
There are two places where breadcrumbs are used in SentryInstrumentation: beginExecuteOperation and instrumentDataFetcher. I'm not sure about beginExecuteOperation, but instrumentDataFetcher is mostly where I want to enrich the breadcrumb.
Solution Brainstorm
Nested class in SentryInstrumentation
interface DataFetcherBreadcrumbEnricher {
void enrich(DataFetchingEnvironment environment, Breadcrumb breadcrumb);
}
Hey @ooraini thanks for opening this issue.
We're thinking this through and our current solution would be to add a Hint containing more details which you could then use in beforeBreadcrumb to enrich the breadcrumb. Would this work for you?
If yes, what GraphQL data would you need? Just DataFetchingEnvironment, or anything else?
For this to work you'd have to register a beforeBreadcrumb callback, similar to what is shown in docs but for Spring Boot you can provide a bean of type SentryOptions.BeforeBreadcrumbCallback which should automatically be picked up and used by auto init of the Spring Boot SDK.
Hi @adinauer,
We're thinking this through and our current solution would be to add a Hint containing more details which you could then use in beforeBreadcrumb to enrich the breadcrumb. Would this work for you?
As long as I can access the DataFetchingEnvironment , it should work out.
If yes, what GraphQL data would you need? Just DataFetchingEnvironment, or anything else?
The DataFetchingEnvironment contains everything that I would need, I thought of including the result of the data fetcher as well, but that seems an overkill, and BeforeSendCallback already has it.
For this to work you'd have to register a beforeBreadcrumb callback,
👍🏻
Hi @adinauer @lbloder any timeline on 8.0 release? If it's further away, can we backport this? Similarly for #3412
Hey @ooraini, just coming back from an extended vacation, we'll discuss internally whether we want to include more changes in the 8.0 release. I'm hoping we'll do a beta soon and then a release some time after that. Ideally I'd like to avoid backporting and focus on the new major instead. If it takes too long we can revisit.
We're closing in on rc.1 and GA release of v8, so we're not going to backport. Sorry for the wait.
All good, I tried the beta release and it's working as expected. Thanks!