feat(strawberry): Gate GraphQL data collection behind data_collection option - #6887
Conversation
…ption The graphene integration now honors the experimental structured data_collection configuration when deciding whether to attach GraphQL-specific data. When data_collection is set, graphql.document controls whether request.api_target is marked as graphql on error events and whether the graphql.document attribute is attached to query/mutation spans (both streamed and transaction-embedded). When data_collection is not configured, behavior falls back to the existing send_default_pii gating, and data_collection takes precedence when both options are set. Adds tests covering the new gating for the event processor and both span paths, including precedence over send_default_pii.
… option Apply the data_collection option to the Strawberry integration so that graphql.document, request data, and variables are only collected when explicitly enabled. send_default_pii is used as a fallback only when data_collection is not configured. GraphQL operation names are now always captured when available, independent of document or PII settings.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit a6055cd. Configure here.
| execution_context.operation_name | ||
| ) | ||
|
|
||
| request_data["data"] = execution_context_data |
There was a problem hiding this comment.
Empty request data written
Low Severity
When data_collection is enabled but document and variables are both off and there is no operationName, the event processor still assigns request.data to an empty dict. That adds empty request payload on events where nothing GraphQL-related was selected for collection.
Reviewed by Cursor Bugbot for commit a6055cd. Configure here.
Codecov Results 📊✅ 99231 passed | ⏭️ 6806 skipped | Total: 106037 | Pass Rate: 93.58% | Execution Time: 353m 30s 📊 Comparison with Base Branch
All tests are passing successfully. ✅ Patch coverage is 100.00%. Project has 2569 uncovered lines. Files with missing lines (1)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 89.55% 89.55% —%
==========================================
Files 193 193 —
Lines 24570 24588 +18
Branches 8726 8744 +18
==========================================
+ Hits 22002 22019 +17
- Misses 2568 2569 +1
- Partials 1405 1407 +2Generated by Codecov Action |


Apply the
data_collectionoption to the Strawberry integration so thatgraphql.document, request data, and variables are only collected whenexplicitly enabled.
send_default_piiis used as a fallback only whendata_collectionis not configured.GraphQL operation names are now always captured when available,
independent of document or PII settings. Tests are updated to assert the
new behavior.
Refs PY-2585
Refs #6745