DiederikvandenB / apollo-link-sentry

Apollo Link middleware which enriches SentryJS with GraphQL data
MIT License
123 stars 36 forks source link

Add sentry-trace header #428

Closed revmischa closed 2 years ago

revmischa commented 2 years ago

Would it be possible to automatically add the sentry-trace header to all requests to correlate backend and frontend errors?

https://docs.sentry.io/platforms/javascript/performance/connect-services/

spawnia commented 2 years ago

https://docs.sentry.io/platforms/javascript/guides/react/performance/instrumentation/automatic-instrumentation does this. We had to make sure that the Sentry setup is imported before the Apollo setup though, due to https://github.com/getsentry/sentry-javascript/issues/2860#issuecomment-684514367

// The side effect of patching fetch() has to occur before configuring Apollo Client
// https://github.com/getsentry/sentry-javascript/issues/2860#issuecomment-684514367
import './sentry';
import { ApolloProvider } from '@apollo/client';
mmahalwy commented 2 years ago

@spawnia sorry following up on this cause I noticed the instructions suggest adding:

    new Sentry.BrowserTracing({ traceFetch: false }),

which would disable the sentry-trace header.

mmahalwy commented 2 years ago

I guess it's not obvious in the README section if 1 and 2 are alternatives or both are needed

Natureshadow commented 1 year ago

But if the README says we should disable the fetch instrumentation for GraphQL, then we still don't get a trace ID, right, @spawnia?