Skip to content

Conversation

rgaignault
Copy link
Contributor

@rgaignault rgaignault commented Aug 28, 2025

Motivation

GraphQL calls in RUM currently appear as generic POST /graphql entries, making it hard to distinguish or debug specific operations. Mobile SDKs already support GraphQL OOTB tracking, but the Browser SDK lacked equivalent functionality. This PR introduces native GraphQL request enrichment so operations can be meaningfully identified in RUM without relying on beforeSend customization.

Changes

New configuration option :

  • allowedGraphQlUrls: declares which endpoints should be treated as GraphQL. Accepts strings, regex, or function matchers, with optional trackPayload.

Detects matching GraphQL requests and enriches resource events with:
operationType, operationName ,variables, payload (query body, optional via trackPayload, truncated to 32KB)

Test instructions

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.

@rgaignault rgaignault requested a review from a team as a code owner August 28, 2025 07:02
@datadog-datadog-prod-us1
Copy link

datadog-datadog-prod-us1 bot commented Aug 28, 2025

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage
Patch Coverage: 93.75%
Total Coverage: 92.62% (+0.01%)

View detailed report

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 0e6b39f | Docs | Was this helpful? Give us feedback!

Copy link

cit-pr-commenter bot commented Aug 28, 2025

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 156.51 KiB 157.70 KiB 1.19 KiB 0.76%
Rum Recorder 19.53 KiB 19.53 KiB 0 B 0.00%
Rum Profiler 5.18 KiB 5.18 KiB 0 B 0.00%
Logs 55.12 KiB 55.14 KiB 25 B 0.04%
Flagging N/A 931 B 931 B N/A%
Rum Slim 114.29 KiB 115.47 KiB 1.18 KiB 1.03%
Worker 23.60 KiB 23.60 KiB 0 B 0.00%
🚀 CPU Performance
Action Name Base Average Cpu Time (ms) Local Average Cpu Time (ms) 𝚫
addglobalcontext 0.012 0.007 -0.005
addaction 0.041 0.020 -0.021
addtiming 0.010 0.005 -0.005
adderror 0.039 0.018 -0.021
startstopsessionreplayrecording 0.002 0.001 -0.001
startview 0.012 0.007 -0.005
logmessage 0.050 0.023 -0.026
🧠 Memory Performance
Action Name Base Consumption Memory (bytes) Local Consumption Memory (bytes) 𝚫 (bytes)
addglobalcontext 25.15 KiB 25.98 KiB 846 B
addaction 44.90 KiB 46.65 KiB 1.75 KiB
addtiming 24.24 KiB 25.70 KiB 1.46 KiB
adderror 51.37 KiB 49.47 KiB -1954 B
startstopsessionreplayrecording 23.92 KiB 24.41 KiB 505 B
startview 423.17 KiB 422.94 KiB -241 B
logmessage 43.91 KiB 41.37 KiB -2600 B

🔗 RealWorld

@rgaignault
Copy link
Contributor Author

/to-staging

@dd-devflow-routing-codex
Copy link

dd-devflow-routing-codex bot commented Sep 2, 2025

View all feedbacks in Devflow UI.

2025-09-02 11:49:46 UTC ℹ️ Start processing command /to-staging


2025-09-02 11:49:56 UTC ℹ️ Branch Integration: starting soon, merge expected in approximately 0s (p90)

Commit 079d9195f2 will soon be integrated into staging-36.


2025-09-02 11:50:08 UTC 🚨 Branch Integration: this merge request has conflicts which couldn't be solved automatically

We couldn't automatically merge the commit 079d9195f2 into staging-36!

To solve the conflicts directly in Github, click here to create a fix pull request.

Alternatively, you can also click here reset the integration branch or use the following Slack command: /devflow reset-branch -r browser-sdk -b staging-36

@DataDog DataDog deleted a comment from dd-devflow-routing-codex bot Sep 2, 2025
@rgaignault
Copy link
Contributor Author

/to-staging

@dd-devflow-routing-codex
Copy link

dd-devflow-routing-codex bot commented Sep 2, 2025

View all feedbacks in Devflow UI.

2025-09-02 12:28:43 UTC ℹ️ Start processing command /to-staging


2025-09-02 12:28:57 UTC ℹ️ Branch Integration: starting soon, merge expected in approximately 0s (p90)

Commit f396a31845 will soon be integrated into staging-36.


2025-09-02 12:40:47 UTC ℹ️ Branch Integration: this commit was successfully integrated

Commit f396a31845 has been merged into staging-36 in merge commit 2b96c832fb.

Check out the triggered pipeline on Gitlab 🦊

If you need to revert this integration, you can use the following command: /code revert-integration -b staging-36

dd-mergequeue bot added a commit that referenced this pull request Sep 2, 2025
@dd-devflow dd-devflow bot added the staging-36 label Sep 2, 2025
return {}
}

const graphqlMetadata = extractGraphQlMetadata(request.init?.body, graphQlConfig.trackPayload)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ question: ‏does anything prevent customers to use Request for their calls? cf input field of RequestCompleteEvent

Copy link
Contributor Author

@rgaignault rgaignault Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I guess no but it's a readable stream so we can not access it at this time, what are you thoughts about handling this case ?

Copy link
Collaborator

@bcaudan bcaudan Sep 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my understanding, you can use Request with a string body, so I'd support this usage like we already do in fetchObservable.

@rgaignault
Copy link
Contributor Author

/to-staging

@dd-devflow-routing-codex
Copy link

dd-devflow-routing-codex bot commented Sep 8, 2025

View all feedbacks in Devflow UI.

2025-09-08 09:42:16 UTC ℹ️ Start processing command /to-staging


2025-09-08 09:42:26 UTC ℹ️ Branch Integration: starting soon, merge expected in approximately 0s (p90)

Commit f396a31845 will soon be integrated into staging-37.


2025-09-08 09:53:07 UTC ℹ️ Branch Integration: this commit was successfully integrated

Commit f396a31845 has been merged into staging-37 in merge commit 635a7b715d.

Check out the triggered pipeline on Gitlab 🦊

If you need to revert this integration, you can use the following command: /code revert-integration -b staging-37

dd-mergequeue bot added a commit that referenced this pull request Sep 8, 2025
@dd-devflow dd-devflow bot added the staging-37 label Sep 8, 2025
@DataDog DataDog deleted a comment from bcaudan Sep 10, 2025
@BenoitZugmeyer BenoitZugmeyer self-requested a review September 12, 2025 12:32
Copy link
Member

@BenoitZugmeyer BenoitZugmeyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a e2e scenario?

Comment on lines +10 to +14
operationType: 'query' | 'mutation' | 'subscription'
operationName?: string
variables?: string
payload?: string
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, i'm just a GraphQL fan checking in. Feel free to disregard.

Just curious: do we also plan to supporting persisted queries or anything in the extensions field? Persisted queries aren't officially in the GraphQL spec but supported by Apollo and Relay. When the persisted query id/hash is provided, the query document itself won't be provided. This would allow customers to figure out what was executed by the client. It might be worth looking into saving the entire extensions field. There shouldn't be anything privacy sensitive in there if they're following the spec and only use it for "implementation-specific additional information."

Apollo seems to include it in the extensions field:

{
  operationName: 'MyQuery',
  variables: null,
  extensions: {
    persistedQuery: {
      version: 1,
      sha256Hash: hashOfQuery
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants