Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow user to hook into Breadcrumb in SentryInstrumentation #3413

Open
ooraini opened this issue May 9, 2024 · 2 comments
Open

Allow user to hook into Breadcrumb in SentryInstrumentation #3413

ooraini opened this issue May 9, 2024 · 2 comments

Comments

@ooraini
Copy link

ooraini commented May 9, 2024

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);
}
@adinauer
Copy link
Member

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.

@ooraini
Copy link
Author

ooraini commented May 10, 2024

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,

👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Status: Needs Discussion
Development

No branches or pull requests

3 participants