sentry-java icon indicating copy to clipboard operation
sentry-java copied to clipboard

Allow user to hook into Breadcrumb in SentryInstrumentation

Open ooraini opened this issue 1 year ago • 4 comments

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);
}

ooraini avatar May 09 '24 16:05 ooraini

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.

adinauer avatar May 10 '24 09:05 adinauer

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,

👍🏻

ooraini avatar May 10 '24 13:05 ooraini

Hi @adinauer @lbloder any timeline on 8.0 release? If it's further away, can we backport this? Similarly for #3412

ooraini avatar Aug 21 '24 23:08 ooraini

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.

adinauer avatar Aug 23 '24 05:08 adinauer

We're closing in on rc.1 and GA release of v8, so we're not going to backport. Sorry for the wait.

adinauer avatar Nov 18 '24 13:11 adinauer

All good, I tried the beta release and it's working as expected. Thanks!

ooraini avatar Nov 18 '24 13:11 ooraini