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

Fix error reporting when trace data is not included #7136

Merged
merged 21 commits into from
Feb 6, 2023

Conversation

trevor-scheer
Copy link
Member

@trevor-scheer trevor-scheer commented Nov 9, 2022

This is a 2-part change which requires an update to the gateway runtime as well. Related PR: apollographql/federation#2242

It was brought to our attention that trace information w.r.t. subgraph errors is incorrect in the case that there is no trace in the subgraph response (i.e. no ftv1 support in the subgraph or fieldLevelInstrumentation is 0 or returns 0).

With this change:

  • Errors reported by subgraphs (with no trace data in the response) are now accurately reflected in the numeric error stats
  • Operations that receive errors from subgraphs (with no trace data in the response) are no longer sent as incomplete, error-less traces

The gateway change now collects errors separately when no trace data is found and passes that error information (subgraph and error path) along with the other metrics data for the plugin to consume. The plugin uses the subgraph name and error path in order to add error stat information to the tree.

@netlify
Copy link

netlify bot commented Nov 9, 2022

Deploy Preview for apollo-server-docs ready!

Name Link
🔨 Latest commit 5548ec0
🔍 Latest deploy log https://app.netlify.com/sites/apollo-server-docs/deploys/63e168ff4abc640009deab40
😎 Deploy Preview https://deploy-preview-7136--apollo-server-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Nov 9, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 5548ec0:

Sandbox Source
Apollo Server Typescript Configuration
Apollo Server Configuration

@trevor-scheer trevor-scheer force-pushed the trevor/usage-reporting-errors branch 4 times, most recently from dff19ff to 78863f6 Compare November 10, 2022 00:00
Copy link
Member

@glasser glasser left a comment

Choose a reason for hiding this comment

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

The broad structure here seems good but the tests suggest there's a bug preventing the fix from working. (Maybe the version of gateway loaded is wrong?)

Also I'm sure you know this but a ton more comments would be helpful, both about the new stuff and about the other stuff we've discovered today that wasn't obvious.

package.json Outdated
@@ -39,7 +39,9 @@
},
"devDependencies": {
"@apollo/client": "3.7.1",
"@apollo/gateway": "https://pkg.csb.dev/apollographql/federation/commit/ca4c450d/@apollo/gateway",
Copy link
Member

Choose a reason for hiding this comment

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

reminder to fix this. (is there a circular dependency issue where we can't publish one until the other is done and vice versa? this is just for tests though right?)

Copy link
Member Author

Choose a reason for hiding this comment

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

The "correct" way to do this would be publish gateway interface -> gateway -> server, but yes it is just tests.

packages/gateway-interface/src/index.ts Outdated Show resolved Hide resolved
Copy link
Member

@glasser glasser left a comment

Choose a reason for hiding this comment

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

Other than those minor notes this looks good. The PR title/description could use an update to describe this kinda subtle issue, and also a changeset.

packages/gateway-interface/src/index.ts Outdated Show resolved Hide resolved
packages/server/src/plugin/usageReporting/plugin.ts Outdated Show resolved Hide resolved
packages/server/src/plugin/usageReporting/stats.ts Outdated Show resolved Hide resolved
@trevor-scheer trevor-scheer changed the title WIP: Fix error reporting when trace data is not included Fix error reporting when trace data is not included Jan 25, 2023
trevor-scheer added a commit that referenced this pull request Jan 25, 2023
Precursor to:
#7136
apollographql/federation#2242

This interface needs to be published in order to properly land and
publish the required change to gateway, which the Apollo Server change
depends on.
@github-actions github-actions bot mentioned this pull request Jan 25, 2023
trevor-scheer pushed a commit that referenced this pull request Jan 25, 2023
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @apollo/server-gateway-interface@1.1.0

### Minor Changes

- [#7325](#7325)
[`e0f959a63`](e0f959a)
Thanks [@trevor-scheer](https://github.com/trevor-scheer)! - Add
optional `nonFtv1ErrorPaths` to Gateway metrics data. This change is a
prerequisite to:
    -   <apollographql/federation#2242>
    -   <#7136>

## @apollo/server-integration-testsuite@4.3.2

### Patch Changes

- [#7316](#7316)
[`37d884650`](37d8846)
Thanks [@renovate](https://github.com/apps/renovate)! - Update
graphql-http dependency

- Updated dependencies
\[[`f246ddb71`](f246ddb),
[`e25cb58ff`](e25cb58)]:
    -   @apollo/server@4.3.2

## @apollo/server@4.3.2

### Patch Changes

- [#7314](#7314)
[`f246ddb71`](f246ddb)
Thanks [@trevor-scheer](https://github.com/trevor-scheer)! - Add an
`__identity` property to `HeaderMap` class to disallow standard `Map`s
(in TypeScript).

This ensures that typechecking occurs on fields which are declared to
accept a
      `HeaderMap` (notably, the `httpGraphQLRequest.headers` option to
`ApolloServer.executeHTTPGraphQLRequest` and the `http.headers` option
to
`ApolloServer.executeOperation`). This might be a breaking change for
integration authors, but should be easily fixed by switching from `new
    Map<string, string>()` to `new HeaderMap()`.

- [#7326](#7326)
[`e25cb58ff`](e25cb58)
Thanks [@trevor-scheer](https://github.com/trevor-scheer)! - Pin
`node-abort-controller` version to avoid breaking change. Apollo Server
users can enter a broken state if they update their package-lock.json
due to a breaking change in a minor release of the mentioned package.

Ref: <southpolesteve/node-abort-controller#39>

- Updated dependencies
\[[`e0f959a63`](e0f959a)]:
    -   @apollo/server-gateway-interface@1.1.0

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
trevor-scheer added a commit to apollographql/federation that referenced this pull request Jan 25, 2023
This commit precedes apollographql/apollo-server#7136

For the mentioned PR (full context within), the gateway needs to capture error information from subgraphs with no trace data separately and report them within the metrics object that's shared with the inline trace plugin.

This change only takes effect for subgraphs with no ftv1 support or when fieldLevelInstrumentation on the inline trace plugin is set to 0 or returns 0.
'@apollo/server': patch
---

Errors reported by subgraphs (with no trace data in the response) are now accurately reflected in the numeric error stats.
Copy link
Member

Choose a reason for hiding this comment

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

Does this changeset (and PR description) need to note that a particular version of Gateway is also needed to have the issue be actually fixed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Added in e1b8122 (with a FIXME to plug in final gateway version)

package.json Outdated
@@ -38,7 +38,9 @@
},
"devDependencies": {
"@apollo/client": "3.7.5",
"@apollo/gateway": "https://pkg.csb.dev/apollographql/federation/commit/166fdd24/@apollo/gateway",
Copy link
Member

Choose a reason for hiding this comment

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

Would be nice to avoid this but I guess the gateway release process is slow.

Copy link
Member Author

Choose a reason for hiding this comment

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

This will become the actual gateway version once the patch is released, won't land this until then

package.json Outdated
"@apollo/server-plugin-landing-page-graphql-playground": "4.0.0",
"@apollo/subgraph": "https://pkg.csb.dev/apollographql/federation/commit/166fdd24/@apollo/subgraph",
Copy link
Member

Choose a reason for hiding this comment

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

Why is this needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Probably could've always been just the current version of subgraph but this will be latest once the patch release is published

@trevor-scheer trevor-scheer merged commit 8c635d1 into main Feb 6, 2023
@trevor-scheer trevor-scheer deleted the trevor/usage-reporting-errors branch February 6, 2023 21:59
@github-actions github-actions bot mentioned this pull request Feb 6, 2023
trevor-scheer pushed a commit that referenced this pull request Feb 6, 2023
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @apollo/server-integration-testsuite@4.3.3

### Patch Changes

- [#7338](#7338)
[`01bc39838`](01bc398)
Thanks [@trevor-scheer](https://github.com/trevor-scheer)! - Update
graphql-http to 1.13.0

- Updated dependencies
\[[`9de18b34c`](9de18b3),
[`8c635d104`](8c635d1)]:
    -   @apollo/server@4.3.3

## @apollo/server@4.3.3

### Patch Changes

- [#7331](#7331)
[`9de18b34c`](9de18b3)
Thanks [@trevor-scheer](https://github.com/trevor-scheer)! - Unpin
`node-abort-controller` and update to latest unbreaking patch

- [#7136](#7136)
[`8c635d104`](8c635d1)
Thanks [@trevor-scheer](https://github.com/trevor-scheer)! - Errors
reported by subgraphs (with no trace data in the response) are now
accurately reflected in the numeric error stats.

Operations that receive errors from subgraphs (with no trace data in the
response) are no longer sent as incomplete, error-less traces.

Note: in order for this fix to take effect, your `@apollo/gateway`
version must be updated to v2.3.1 or later.

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants