-
Notifications
You must be signed in to change notification settings - Fork 159
RUM-12441 Graphql errors #2552
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
base: develop
Are you sure you want to change the base?
RUM-12441 Graphql errors #2552
Conversation
2917f4b to
85a1acc
Compare
This comment has been minimized.
This comment has been minimized.
35f7626 to
3fc640f
Compare
| // Extension to make Path conform to Equatable for testing | ||
| extension RUMResourceEvent.Resource.Graphql.Errors.Path: Equatable { | ||
| public static func == (lhs: RUMResourceEvent.Resource.Graphql.Errors.Path, rhs: RUMResourceEvent.Resource.Graphql.Errors.Path) -> Bool { | ||
| switch (lhs, rhs) { | ||
| case (.string(let lhsValue), .string(let rhsValue)): | ||
| return lhsValue == rhsValue | ||
| case (.integer(let lhsValue), .integer(let rhsValue)): | ||
| return lhsValue == rhsValue | ||
| default: | ||
| return false | ||
| } | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this extension to be able to do XCTAssertEqual on a Path. Not sure if there is a better way to make this testable.
|
|
||
| init(from decoder: Decoder) throws { | ||
| let container = try decoder.container(keyedBy: CodingKeys.self) | ||
| hasErrors = container.contains(.errors) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
smart!
DatadogRUM/Sources/Instrumentation/Resources/URLSessionRUMResourcesHandler.swift
Outdated
Show resolved
Hide resolved
maxep
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, well done!
763d032 to
3ef2031
Compare
|
Forced pushed to resolve merge conflicts with the develop branch. |
|
Hi @barboraplasovska is this ready to merge? |
What and why?
GraphQL APIs follow a different error model than REST APIs, they return HTTP
200 OKstatus codes even when operations fail with errors included in the response body under anerrorskey. Without parsing the response body, these errors would go unnoticed in RUM monitoring.This PR adds support for automatically detecting, parsing, and reporting GraphQL errors in RUM resource events. When a GraphQL request completes with errors in the response, the SDK now captures and includes them in the resource event.
How?
When a request completes with a JSON response, we check for the presence of an
errorskey. If found, the response body is passed along to the resource scope where it's decoded according to the GraphQL spec and populated into the resource event'sgraphql.errorsarray andgraphql.errorCountfields. (cc PR onrum_events_format).Review checklist
make api-surface)