Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GraphQL: Capture user-provided error extension values #4325

Merged
merged 8 commits into from
Feb 14, 2025

Conversation

marcotc
Copy link
Member

@marcotc marcotc commented Jan 28, 2025

A follow up from #4177, this PR allows users to capture custom error fields (called extensions in GraphQL).

Here's an example of an error with extensions (link):

{
  "errors": [
    {
      "message": "Cannot query field \"__typenam\" on type \"Query\".",
      "locations": [
        {
          "line": 1,
          "column": 2
        }
      ],
      "extensions": {
        "code": "GRAPHQL_VALIDATION_FAILED",
        "stacktrace": [
          "GraphQLError: Cannot query field \"__typenam\" on type \"Query\".",
          "    at Object.Field (/my_project/node_modules/graphql/validation/rules/FieldsOnCorrectTypeRule.js:48:31)",
          "    ...additional lines..."
        ]
      }
    }
  ]
}

extensions can contain any arbitrary data, but are often important for error debugging.
Because extensions can contain PII, or pretty much any arbitrary user-provided information, the extensions that are allowed to be capture by dd-trace-rb have to be added to a list in the DD_TRACE_GRAPHQL_ERROR_EXTENSIONS configuration.

Change log entry
No. This will be covered by #4177.

How to test the change?
All changes have automated tests.

Copy link

github-actions bot commented Jan 28, 2025

Thank you for updating Change log entry section 👏

Visited at: 2025-01-31 22:26:52 UTC

@github-actions github-actions bot added integrations Involves tracing integrations tracing labels Jan 28, 2025
@marcotc marcotc changed the title GraphQL: Report multiple query errors GraphQL: Capture user-provided error extension values Jan 28, 2025
@marcotc marcotc changed the title GraphQL: Capture user-provided error extension values GraphQL: Capture user-provided error extension values Jan 28, 2025
@datadog-datadog-prod-us1
Copy link
Contributor

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

Datadog Report

Branch report: graphql-error-event-ext
Commit report: 8b58748
Test service: dd-trace-rb

✅ 0 Failed, 20131 Passed, 1361 Skipped, 3m 12.89s Total Time

@pr-commenter
Copy link

pr-commenter bot commented Jan 28, 2025

Benchmarks

Benchmark execution time: 2025-02-14 20:31:20

Comparing candidate commit 8b58748 in PR branch graphql-error-event-ext with baseline commit aa7e0da in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 31 metrics, 2 unstable metrics.

@marcotc marcotc force-pushed the graphql-error-event-ext branch from 2e6fa76 to 0c4de1a Compare January 28, 2025 22:47
@marcotc marcotc marked this pull request as ready for review January 31, 2025 22:20
@marcotc marcotc requested review from a team as code owners January 31, 2025 22:20
@codecov-commenter
Copy link

codecov-commenter commented Jan 31, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.70%. Comparing base (aa7e0da) to head (8b58748).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4325      +/-   ##
==========================================
- Coverage   97.71%   97.70%   -0.01%     
==========================================
  Files        1353     1355       +2     
  Lines       82975    83051      +76     
  Branches     4213     4218       +5     
==========================================
+ Hits        81078    81144      +66     
- Misses       1897     1907      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@buraizu buraizu left a comment

Choose a reason for hiding this comment

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

Approving with a minor update requested

Copy link
Member

@Strech Strech left a comment

Choose a reason for hiding this comment

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

I have a minor suggestion to avoid undefined method on NilClass

Base automatically changed from graphql-error-event to master February 14, 2025 19:06
@marcotc marcotc requested a review from a team as a code owner February 14, 2025 19:06
@marcotc marcotc force-pushed the graphql-error-event-ext branch from b735813 to 8b58748 Compare February 14, 2025 20:07
@github-actions github-actions bot added the core Involves Datadog core libraries label Feb 14, 2025
@marcotc marcotc merged commit 92e97fa into master Feb 14, 2025
486 checks passed
@marcotc marcotc deleted the graphql-error-event-ext branch February 14, 2025 22:56
@github-actions github-actions bot added this to the 2.11.0 milestone Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Involves Datadog core libraries integrations Involves tracing integrations tracing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants