Setting the transaction name for client-side GraphQL requests #10433
Replies: 2 comments
-
I'm also interested in this. At the moment it's not very helpful just seeing |
Beta Was this translation helpful? Give feedback.
-
@lforst (you promised not to get mad at me 😛) In case it helps, here's a little more context for what I was originally trying to accomplish:
It seems like the transaction name is something we're better off not setting? I was thinking it might also be useful when looking at performance/transaction data if we wanted to identify any slow/problematic operations. As @nevace mentioned, without doing anything these will just show up as |
Beta Was this translation helpful? Give feedback.
-
Hello 👋
We're using
@sentry/nextjs
along with theurql
GraphQL client and I was curious to know the recommended way for setting the transaction name.What we'd like to accomplish
Rather than see numerous transactions for
POST /graphql
, we'd like to see transactions named after their corresponding operation name.What we've tried
Initially, we were using
as per the docs, but there are two issues we noticed:
setTransactionName
was recently deprecated, but more importantlyThe deprecation mentions using extra or tags, but those are also set on the current scope and would exhibit the same issue we're seeing with
setTransactionName
.We also considered
Sentry.addEventProcessor
, but the incomingevent
andhint
doesn't contain the information needed for us to know the operation name (the same goes forbeforeSendTransaction
).We noticed the
@sentry/utils
package exposes aaddFetchInstrumentationHandler
function in which the handler would have access to the fetch request body (which could be used to extract the operation name), but@sentry/utils
is technically not part of the public API.Other options?
I suspect one way to accomplish this might be to configure our GraphQL client to use a custom fetch implementation that manually creates a Sentry span/transaction and configure Sentry to not automatically instrument fetch requests to our GraphQL endpoint.
I'm ultimately wondering if there are some other options that we haven't considered (especially taking into account what v8 of the SDK will offer) and/or what the official recommendation is to accomplish something like this. Thanks in advance!
Related Issues
#3087
#5442
Beta Was this translation helpful? Give feedback.
All reactions