-
Notifications
You must be signed in to change notification settings - Fork 2k
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
refactor: Graph Manager (Engine) reporting "extensions" become "plugins". #3998
refactor: Graph Manager (Engine) reporting "extensions" become "plugins". #3998
Conversation
…ns". Similar to 6009d8a (#3991) and 68cbc93 (#3997), which migrated the tracing and cache-control extensions to the (newer) request pipeline plugin API, this commit introduces: - Internally, a `plugin` named export which is utilized by the `agent`'s `newExtension` method to provide a plugin which is instrumented to transmit metrics to Apollo Graph Manager. This plugin is meant to replicate the behavior of the `EngineReportingExtension` class which, as of this commit, still lives besides it. - Externally, a `federatedPlugin` exported on the main module of the `apollo-engine-reporting` package. This plugin is meant to replicate the behavior of the `EngineFederatedTracingExtension` class (also exported on the main module) which, again as of this commit, still lives besides it! Again, the delta of the commits seemed more confusing by allowing a natural `diff` to be made of it, I've left the extensions in place so they can be compared - presumably side-by-side in an editor - on the same commit. An (immediate) subsequent commit will remove the extension.
This fixes the failing tests which correctly surfaced on the last commit. Previously, prior to the new plugin API, the Apollo Engine Reporting mechanism was implemented using `graphql-extensions`, the API for which didn't invoke `requestDidStart` until _after_ APQ had been negotiated. The new plugin API starts its `requestDidStart` _before_ APQ validation and various other assertions which weren't included in the `requestDidStart` life-cycle, even if they perhaps should be in terms of error reporting. The new plugin API is able to properly capture such errors within its `didEncounterErrors` lifecycle hook (thanks to #3614, which intentionally captures these failures so plugin authors can accurately react to them), however, for behavioral consistency reasons, we will still special-case those errors and maintain the legacy behavior to avoid a breaking change. We can reconsider this in a future version of Apollo Engine Reporting (AS3, perhaps!). Ref: #3614 Ref: #3627 Ref: #3638
The plugin implementation brought in de7ba72 supersedes the need for this implementation!
Sorry for the delay. Targeting tomorrow, high priority. |
Ugh, I really meant to get to this today, but time is a slippery thing. |
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.
Really glad you're doing this! And thanks for making this so reviewable.
This was inadvertently removed in the re-factor. Ref: https://github.com/apollographql/apollo-server/pull/3998/files#r414901517
...and destructuring.
This eliminates the need to guard for the presence of `metrics` on the `requestContext` within plugins who are calling `requestDidStart`. Ref: #3998 (comment)
a3c378b
to
8ca5d11
Compare
As noted in review within [[1]], there wasn't really a compelling reason for this to be kept separately from the other tree-building bits which existed within `ensurePreflight`. [1]: #3998 (comment)
…tring`. The use of `document` and `source` is the standard within the plugin API and the request pipeline, so these names should be more natural going forward. This wouldn't have been possible without a breaking change, but we're already doing that.
…abernix/migrate-engine-reporting-exts-to-plugin-api
…to abernix/migrate-engine-reporting-exts-to-plugin-api
I may re-visit this consideration.
…rce`. Leverages new life-cycle `didResolveSource` which was introduced by [[PR #4076]] and inspired by this [[comment]]. This is much nicer! [PR #4076]: #4076 [Comment]: https://github.com/apollographql/apollo-server/pull/3998/files#r414911049
@glasser, are you able to confirm this belief and that it should be okay?
…w traced." This reverts commit 6d4777d.
Previously, I introduced a work-around for this in 78a4cb7, though that is no longer necessary with the introduction of `didResolveSource` in #4076 I'm thrilled to remove this! Ref: #3998 (comment)
…to abernix/migrate-engine-reporting-exts-to-plugin-api
… failure. Addresses feedback in below referenced [[Comment]]. If operation resolution (parsing and validating the document followed by selecting the correct operation) resulted in the population of the `operationName`, we'll use that. (For anonymous operations, `requestContext.operationName` is null, which we represent here as the empty string.) If the user explicitly specified an `operationName` in their request but operation resolution failed (due to parse or validation errors or because there is no operation with that name in the document), we still put _that_ user-supplied `operationName` in the trace. This allows the error to be better understood in Graph Manager. (We are considering changing the behavior of `operationName` in these three error cases; see [[#3465]] below for details.) [Comment]: #3998 (comment) [#3465]: #3465
This should prove to be more ergonomic, and also allow us to attach other useful properties to this object (for either external or internal use) in the future. Also, adds a test to make sure we're passing _something_! Ref: #3998 (comment)
…to abernix/migrate-engine-reporting-exts-to-plugin-api
…abernix/migrate-engine-reporting-exts-to-plugin-api
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.
Other than noting the possibly unintentional possibly irrelevant change around logger
this looks good to me.
…xts-to-plugin-api
…rate-engine-reporting-exts-to-plugin-api
@glasser Could you zoom me back into the specifics of the |
There is a TreeBuilder also takes a That was the only (remaining?) use of this logger within the request-specific When you changed
( So the effect here is that the TreeBuilder's warning now uses the request-specific logger instead of the engine-reporting-specific logger. While it generally makes sense to use the "most specific" logger for any given logging, it's not cut and dry which of those is "more specific" since one has a specific lifecycle whereas the other has a specific subsystem scope. I think I would lean towards keeping the old behavior. ie, just ignore the logger passed to requestDidStart. But again, it only affects one probably-shouldn't-happen-much warning? |
Thanks for the clarification, @glasser, and I missed this and didn't see de7ba72#r416714696 somehow. 🤷 I recall this now and it was a conscious decision when I recently introduced the I agree that it's less cut and dry than ideal, though the intent of the request-level logger was to capture anything that could have sandbagged a specific request, so in my mind the spirit of using the request logger here is correct, particularly since it could be linked to a specific operation in the same scoped-logger. On the notion that it only affects the one probably-shouldn't-happen-much (I've never seen, or seen reported) warning, and additionally because we don't specify a way to override the request-level logger right now without specific assignment within a plugin, and the relative recency of this, I'm going to leave this as is for now. If you have strong feelings about this, I'm happy to change it. |
Nope, just wanted to make sure it was understood. |
This PR depends on #3988 and #3996 (this PR is targeted to merge into the latter). It is part of an initiative to deprecate all internal usages of the
graphql-extensions
API. Similar work can be seen in the work done to migrate theapollo-tracing
extension (#3991) and theapollo-cache-control
extention (#3997). Similar to those commits, this introduces:plugin
utilized by theagent
'snewExtension
method which generates a plugin wired up to the mechanism which transmit metrics to Apollo Graph Manager ingress. This plugin is meant to replicate the behavior of theEngineReportingExtension
class.federatedPlugin
(i.e. exported on the main module of theapollo-engine-reporting
package), meant to replicate the behavior of theEngineFederatedTracingExtension
class. This plugin provides the functionality currently used by implementing services in a federated configuration to include the Base64-encoded protobuf trace on theftv1
extension of responses from the implementing service. This encoded extension data is consumed by the Apollo Gateway when received from an implementing service.Like the other PRs above, the delta of the commits seemed more confusing by allowing a natural
diff
to be made of it, so I've left the extensions in place alongside the new plugins in the first commit so they can be compared - presumably side-by-side in an editor - on the same commit. A subsequent commit in this PR removes the existing extensions, so you can choose whether you'd like to view it in its totality or commit by commit.