Skip to content

graphqlClientIntegration does not enrich spans for relative URLs #20292

@victorandree

Description

@victorandree

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/browser

SDK Version

10.48.0

Framework Version

No response

Link to Sentry event

https://playground-bg.sentry.io/explore/traces/trace/c2d9ad4d36f94588aa1626c8b9fcf5fa

Reproduction Example/SDK Setup

Reproduction available at https://github.com/victorandree/sentry-graphql-client-repro

Steps to Reproduce

I noticed that nothing interesting was being added to GraphQL request spans, even though I activate the graphqlClientIntegration.

This appears to happen when the GraphQL endpoint URL is relative, in which case neither http.url nor url.full are set when attempting to read it in https://github.com/getsentry/sentry-javascript/blob/develop/packages/browser/src/integrations/graphqlClient.ts#L70. This is evident from the behavior of the fetch instrumentation, which only sets url if the URL is relative (see

function getFetchSpanAttributes(
).

To reproduce:

  1. Configure Sentry browser SDK with the GraphQL client integration.
  2. Do a GraphQL request using fetch to a relative URL: The span WILL NOT be enriched with any GraphQL information.
  3. Do a GraphQL request using fetch to an absolute URL; The span WILL be enriched with GraphQL information, such as graphql.document and an updated description.

Expected Result

GraphQL client integration should work with relative URLs.

Actual Result

Compare these spans for a sample trace run on the reproduction repo:

Trace — c2d9ad4d36f94588aa1626c8b9fcf5fa
├─ graphql.request — gql relative  (46ms)  9b4b15294aff6a52
│  └─ http.client — POST /graphql  (44ms)  8bcb4838bbba12f3
├─ graphql.request — gql absolute  (13ms)  b1881c720e42c0d3
│  └─ http.client — POST http://localhost:4000/graphql (query GetHello)  (11ms)  8d7ed1fc543ef470

Additional Context

No response

Priority

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.

Metadata

Metadata

Assignees

Labels

No fields configured for issues without a type.

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions