Skip to content

feat(strawberry): Gate GraphQL data collection behind data_collection option - #6887

Merged
ericapisani merged 3 commits into
masterfrom
py-2585-strawberry
Jul 28, 2026
Merged

feat(strawberry): Gate GraphQL data collection behind data_collection option#6887
ericapisani merged 3 commits into
masterfrom
py-2585-strawberry

Conversation

@ericapisani

@ericapisani ericapisani commented Jul 24, 2026

Copy link
Copy Markdown
Member

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. Tests are updated to assert the
new behavior.

Refs PY-2585
Refs #6745

…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.
@linear-code

linear-code Bot commented Jul 24, 2026

Copy link
Copy Markdown

PY-2585

@ericapisani
ericapisani changed the base branch from master to py-2585-graphene July 24, 2026 18:30
@ericapisani
ericapisani marked this pull request as ready for review July 24, 2026 18:30
@ericapisani
ericapisani requested a review from a team as a code owner July 24, 2026 18:30

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit a6055cd. Configure here.

@github-actions

github-actions Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

99231 passed | ⏭️ 6806 skipped | Total: 106037 | Pass Rate: 93.58% | Execution Time: 353m 30s

📊 Comparison with Base Branch

Metric Change
Total Tests 📈 +224
Passed Tests 📈 +224
Failed Tests
Skipped Tests

All tests are passing successfully.

✅ Patch coverage is 100.00%. Project has 2569 uncovered lines.
✅ Project coverage is 89.55%. Comparing base (base) to head (head).

Files with missing lines (1)
File Patch % Lines
sentry_sdk/integrations/strawberry.py 100.00% ⚠️ 1 partials
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        +2

Generated by Codecov Action

Base automatically changed from py-2585-graphene to master July 28, 2026 18:22
@ericapisani
ericapisani merged commit 904399e into master Jul 28, 2026
140 checks passed
@ericapisani
ericapisani deleted the py-2585-strawberry branch July 28, 2026 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants