Skip to content

Commit

Permalink
Fix error reporting when trace data is not included (#7136)
Browse files Browse the repository at this point in the history
This is a 2-part change which required 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.

In order to make use of this fix, you must be using the latest gateway patch
`@apollo/gateway@2.3.1` in tandem with this change.
<!--
First, 🌠 thank you 🌠 for taking the time to consider a contribution to
Apollo!

Here are some important details to follow:

* ⏰ Your time is important
To save your precious time, if the contribution you are making will take
more
than an hour, please make sure it has been discussed in an issue first.
          This is especially true for feature requests!
* 💡 Features
Feature requests can be created and discussed within a GitHub Issue. Be
sure to search for existing feature requests (and related issues!) prior
to
opening a new request. If an existing issue covers the need, please
upvote
that issue by using the 👍 emote, rather than opening a new issue.
* 🔌 Integrations
Apollo Server has many web-framework integrations including Express,
Koa,
Hapi and more. When adding a new feature, or fixing a bug, please take a
peak and see if other integrations are also affected. In most cases, the
fix can be applied to the other frameworks as well. Please note that,
since new web-frameworks have a high maintenance cost, pull-requests for
new web-frameworks should be discussed with a project maintainer first.
* 🕷 Bug fixes
These can be created and discussed in this repository. When fixing a
bug,
please _try_ to add a test which verifies the fix. If you cannot, you
should
still submit the PR but we may still ask you (and help you!) to create a
test.
* 📖 Contribution guidelines
Follow
https://github.com/apollographql/apollo-server/blob/main/CONTRIBUTING.md
when submitting a pull request. Make sure existing tests still pass, and
add
          tests for all new behavior.
* ✏️ Explain your pull request
Describe the big picture of your changes here to communicate to what
your
pull request is meant to accomplish. Provide 🔗 links 🔗 to associated
issues!

We hope you will find this to be a positive experience! Open source
contribution can be intimidating and we hope to alleviate that pain as
much as possible. Without following these guidelines, you may be missing
context that can help you succeed with your contribution, which is why
we encourage discussion first. Ultimately, there is no guarantee that we
will be able to merge your pull-request, but by following these
guidelines we can try to avoid disappointment.
-->
  • Loading branch information
trevor-scheer committed Feb 6, 2023
1 parent 0083fd5 commit 8c635d1
Show file tree
Hide file tree
Showing 9 changed files with 2,182 additions and 18 deletions.
9 changes: 9 additions & 0 deletions .changeset/heavy-poets-wink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@apollo/server': patch
---

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.

0 comments on commit 8c635d1

Please sign in to comment.