Skip to content

⚗️ [RUM-11434] GraphQL support#3805

Merged
rgaignault merged 28 commits into
mainfrom
romanG/graph-ql-tracking
Sep 16, 2025
Merged

⚗️ [RUM-11434] GraphQL support#3805
rgaignault merged 28 commits into
mainfrom
romanG/graph-ql-tracking

Conversation

@rgaignault

@rgaignault rgaignault commented Aug 28, 2025

Copy link
Copy Markdown
Contributor

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

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

Copy link
Copy Markdown

⚠️ Tests

⚠️ Warnings

❄️ 2 New flaky tests detected

remote configuration › should resolve an option value from js variable from rum/remoteConfiguration.scenario.ts (Datadog)
createTest.ts:219:3 should resolve an option value from js variable

[Firefox] › ../lib/framework/createTest.ts:219:3 › remote configuration › should resolve an option value from js variable 

    Error: expect(received).toBe(expected) // Object.is equality

    Expected: "js-version"
    Received: undefined

       at rum/remoteConfiguration.scenario.ts:93
...
remote configuration › should resolve an option value from js variable from rum/remoteConfiguration.scenario.ts (Datadog)
createTest.ts:219:3 should resolve an option value from js variable

[Webkit] › ../lib/framework/createTest.ts:219:3 › remote configuration › should resolve an option value from js variable 

    Error: expect(received).toBe(expected) // Object.is equality

    Expected: "js-version"
    Received: undefined

       at rum/remoteConfiguration.scenario.ts:93
...

ℹ️ Info

🧪 All tests passed

🎯 Code Coverage
Patch Coverage: 95.65%
Total Coverage: 92.36% (+0.02%)

View detailed report

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

@cit-pr-commenter

cit-pr-commenter Bot commented Aug 28, 2025

Copy link
Copy Markdown

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 159.66 KiB 160.88 KiB 1.22 KiB 0.76%
Rum Recorder 19.53 KiB 19.53 KiB 1 B 0.01%
Rum Profiler 5.18 KiB 5.18 KiB 1 B 0.02%
Logs 55.73 KiB 55.79 KiB 62 B 0.11%
Flagging N/A 931 B 931 B N/A%
Rum Slim 117.34 KiB 118.53 KiB 1.19 KiB 1.01%
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.006 0.005 -0.001
addaction 0.016 0.015 -0.001
addtiming 0.004 0.003 -0.000
adderror 0.017 0.014 -0.003
startstopsessionreplayrecording 0.001 0.001 -0.000
startview 0.004 0.004 0.000
logmessage 0.019 0.017 -0.002
🧠 Memory Performance
Action Name Base Consumption Memory (bytes) Local Consumption Memory (bytes) 𝚫 (bytes)
addglobalcontext 25.73 KiB 26.09 KiB 365 B
addaction 45.73 KiB 46.49 KiB 771 B
addtiming 24.83 KiB 24.62 KiB -218 B
adderror 52.39 KiB 50.97 KiB -1453 B
startstopsessionreplayrecording 23.72 KiB 23.65 KiB -70 B
startview 424.12 KiB 431.14 KiB 7.02 KiB
logmessage 41.99 KiB 42.67 KiB 697 B

🔗 RealWorld

Comment thread packages/rum-core/src/domain/configuration/configuration.ts Outdated
Comment thread packages/rum-core/src/domain/resource/graphql.ts
Comment thread packages/rum-core/src/domain/resource/resourceCollection.ts Outdated
Comment thread packages/rum-core/src/domain/resource/graphql.ts Outdated
Comment thread packages/rum-core/src/domain/resource/resourceCollection.ts Outdated
Comment thread packages/rum-core/src/domain/resource/resourceCollection.ts Outdated
Comment thread packages/rum-core/src/domain/resource/graphql.ts
Comment thread packages/rum-core/src/domain/resource/graphql.ts Outdated
Comment thread packages/rum-core/src/domain/resource/graphql.ts
Comment thread packages/rum-core/src/domain/resource/graphql.ts Outdated
@rgaignault

Copy link
Copy Markdown
Contributor Author

/to-staging

@dd-devflow-routing-codex

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

Copy link
Copy Markdown

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
Copy Markdown
Contributor Author

/to-staging

@dd-devflow-routing-codex

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

Copy link
Copy Markdown

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
Comment thread packages/rum-core/src/domain/resource/resourceCollection.ts Outdated
Comment thread packages/rum-core/src/domain/resource/resourceCollection.ts Outdated
return {}
}

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

Copy link
Copy Markdown
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

@rgaignault rgaignault Sep 8, 2025

Copy link
Copy Markdown
Contributor Author

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 ?

@bcaudan bcaudan Sep 9, 2025

Copy link
Copy Markdown
Collaborator

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.

Comment thread packages/rum-core/src/domain/resource/graphql.ts
Comment thread packages/rum-core/src/domain/configuration/configuration.ts Outdated
@rgaignault

Copy link
Copy Markdown
Contributor Author

/to-staging

@dd-devflow-routing-codex

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

Copy link
Copy Markdown

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

@BenoitZugmeyer BenoitZugmeyer left a comment

Copy link
Copy Markdown
Member

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 thread packages/rum-core/src/domain/resource/graphql.ts
@rgaignault
rgaignault force-pushed the romanG/graph-ql-tracking branch from 2d5939b to 5bcdde4 Compare September 15, 2025 11:35
Comment thread packages/core/src/browser/xhrObservable.ts Outdated
Comment thread packages/rum-core/src/domain/configuration/configuration.ts Outdated
Comment thread packages/rum-core/src/domain/resource/resourceCollection.ts Outdated
Comment thread packages/rum-core/src/domain/resource/resourceCollection.ts Outdated
Comment thread test/e2e/scenario/rum/graphql.scenario.ts Outdated
Comment thread packages/rum-core/src/domain/resource/graphql.ts
Comment thread packages/rum-core/src/domain/resource/graphql.ts
@bcaudan

bcaudan commented Sep 16, 2025

Copy link
Copy Markdown
Collaborator

💬 suggestion: ‏with the addition of the flag, it should probably be:

- ✨ [RUM-11434] GraphQL support
+ ⚗️ [RUM-11434] GraphQL support

@rgaignault rgaignault changed the title ✨ [RUM-11434] GraphQL support ⚗️ [RUM-11434] GraphQL support Sep 16, 2025
Comment thread packages/rum-core/src/domain/resource/graphql.ts
Comment thread packages/rum-core/src/domain/resource/resourceCollection.ts Outdated
Comment on lines +190 to +192
const requestBody = request.body

return extractGraphQlMetadata(requestBody, graphQlConfig.trackPayload)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

💬 suggestion: let's inline requestBody

Suggested change
const requestBody = request.body
return extractGraphQlMetadata(requestBody, graphQlConfig.trackPayload)
return extractGraphQlMetadata(request.body, graphQlConfig.trackPayload)

@bcaudan bcaudan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice!

@rgaignault
rgaignault merged commit d508410 into main Sep 16, 2025
20 checks passed
@rgaignault
rgaignault deleted the romanG/graph-ql-tracking branch September 16, 2025 15:56
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