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

refactor: Introduce "tracing" plugin and switch request pipeline to use it. #3991

Merged
merged 15 commits into from
May 12, 2020

Conversation

abernix
Copy link
Member

@abernix abernix commented Apr 15, 2020

This commit introduces a plugin (named) export from the apollo-tracing package, which uses the new "plugin" hooks rather than the previous implementation (exported as TracingExtension) which uses the soon-to-be-deprecated "extensions" hooks. The functionality is intended to be identical, in spirit.

Since the delta of the commits was otherwise confusing, I've left the TracingExtension present and exported and will remove it in a subsequent commit.

Briefly summarizing what the necessary changes were:

  1. We no longer use a class instance to house the extension, which was necessitated by the graphql-extensions API. This means that uses of this have been replaced with function scoped variables by the same name.
  2. The logic which actually does the formatting (previously handled by the format method in graphql-extension, now takes place within the plugin API's willSendResponse method.

Finally, this removes the rendered-unused/unnecessary TracingExtension extension after providing its replacement.

abernix added 2 commits April 15, 2020 21:07
…se it.

This commit introduces a `plugin` (named) export from the `apollo-tracing`
package, which uses the new "plugin" hooks rather than the previous
implementation (exported as `TracingExtension`) which uses the
soon-to-be-deprecated "extensions" hooks.  The functionality is intended to
be identical, in spirit.

Since the delta of the commits was otherwise confusing, I've left the
`TracingExtension` present and exported and will remove it in a subsequent
commit.

Briefly summarizing what the necessary changes were:

1. We no longer use a class instance to house the extension, which was
   necessitated by the `graphql-extensions` API.  This means that uses of
   `this` have been replaced with function scoped variables by the same name.
2. The logic which actually does the formatting (previously handled by the
   `format` method in `graphql-extension`, now takes place within the plugin
   API's `willSendResponse` method.
This follows-up 672fa09 and removes the no-longer used/necessary
`TracingExtension` extension which uses the soon-to-be-deprecated
`graphql-extensions` API, now that it has been replaced with an
implementation that uses the plugin API.
@abernix abernix requested a review from trevor-scheer April 15, 2020 18:15
@abernix abernix added this to the Release 2.13.0 milestone Apr 15, 2020
@abernix abernix self-assigned this Apr 15, 2020
Copy link
Member

@trevor-scheer trevor-scheer left a comment

Choose a reason for hiding this comment

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

LGTM!

packages/apollo-server-core/src/ApolloServer.ts Outdated Show resolved Hide resolved
packages/apollo-tracing/src/index.ts Show resolved Hide resolved
packages/apollo-tracing/src/index.ts Outdated Show resolved Hide resolved
packages/apollo-tracing/src/index.ts Show resolved Hide resolved
This package should never have already set it itself prior to this point,
but the circumstance exists that something (anything) else could have
already used the `extensions` sink to attach a value.

This guards against that.
@abernix abernix force-pushed the abernix/migrate-tracing-to-extension-api branch from 5c9ceaa to 7e4cc4b Compare April 16, 2020 11:38
abernix added a commit that referenced this pull request Apr 16, 2020
Inspired by landing some PRs separately and a merge commit that could have
been avoided, but also inspired by the following comment
by @trevor-scheer  whicih made it clear my organization was just a _bit_
off.

Ref: #3991 (comment)
abernix added a commit that referenced this pull request Apr 16, 2020
@abernix abernix force-pushed the abernix/migrate-tracing-to-extension-api branch from c930c24 to 3e9188f Compare April 16, 2020 13:02
abernix added a commit that referenced this pull request Apr 16, 2020
…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.
@glasser
Copy link
Member

glasser commented Apr 16, 2020

While this work (whose review I'll leave up to @trevor-scheer) is worthwhile, can you while you're at it (and as part of describing it in CHANGELOG) update its description/docs to make it clear that it's more or less deprecated? My understanding is that the primary use case of apollo-tracing was for AGM but that only worked via engineproxy; the README does not make it clear that that's a highly deprecated use case. I think there's also some graphql-playground support for it too. I think users get confused a lot into thinking this package (and its enabling flag) has anything to do with modern AGM reporting, but it doesn't.

CHANGELOG.md Show resolved Hide resolved
@abernix abernix modified the milestones: Release 2.13.0, Release 2.14.0 May 4, 2020
abernix added 2 commits May 7, 2020 09:06
This reverts the public messaging about `tracing` deprecation in commit
98bae44, for now, until we can discuss its
fate a bit more, and how we intend on making up for that.
@abernix abernix force-pushed the abernix/migrate-tracing-to-extension-api branch from f7e410e to 4fbf8a7 Compare May 7, 2020 09:29
@abernix
Copy link
Member Author

abernix commented May 7, 2020

I have reverted (ef4ed58) the comment I added to the CHANGELOG.md (98bae44) in response to @glasser's #3991 (comment) about more or less deprecation of this concept since it is, in fact, still very much more or less.

While I agree with us framing it appropriately and clearly, let's do that ASAP outside the scope of this PR.

@abernix abernix added the 🔌 plugins Relates to the request pipeline plugin API label May 8, 2020
@abernix abernix changed the base branch from abernix/add-willResolveField-and-didResolveField to release-2.14.0 May 12, 2020 11:51
@abernix abernix merged commit 13bf447 into release-2.14.0 May 12, 2020
@abernix abernix deleted the abernix/migrate-tracing-to-extension-api branch May 12, 2020 11:51
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🔌 plugins Relates to the request pipeline plugin API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants