sentry-java
sentry-java copied to clipboard
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);
}