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

feat(reporting): Add reportTiming option to EngineReportingOptions #3918

Merged
merged 41 commits into from Jun 16, 2020

Conversation

jsegaran
Copy link
Contributor

@jsegaran jsegaran commented Mar 24, 2020

This PR adds a reportTiming api. It takes a function with parameter GraphQLRequestContextDidResolveOperation or GraphQLRequestContextDidEncounterErrors which returns a promise resolving to a boolean, or it takes a boolean. If the api resolves to false the agent will not instrument the operation or report the query. If the return type is true the agent will act as default and instrument and report the query to Apollo Graph Manager.

Create a new reportTiming api under EngineReportingOption that allows configuration of whether an operation should be traced. Previously there was no way to turn off instrumentation and tracing of requests if an apiKey was provided. The api allows turning off tracing on all requests or selectively turning off tracing based on a specific request shape.

The option can be set via the engine config, and the default is true where every trace gets instrumented and sent to Apollo Graph Manager.

const server = new ApolloServer({
  typeDefs,
  resolvers,
  engine: {
   reportTiming: true,
    /* Other existing options can remain the same. */
  },
});

@jsegaran jsegaran force-pushed the jsegaran/should_report_api branch 2 times, most recently from 39d97cb to b3f6862 Compare March 24, 2020 19:00
@jsegaran jsegaran requested a review from abernix March 25, 2020 16:30
@sankhasp
Copy link

@jsegaran great to see this change is being made, we at Glassdoor are eagerly waiting for this change to get published. @trevor-scheer @abernix -- Thanks for your reviews.

@abernix
Copy link
Member

abernix commented Apr 24, 2020

@sankhasp Just to set expectations — this is currently dependent on #3998 to avoid having to immediately revisit this once we land that (which makes more substantial changes). As soon as that's landed, this is up for rebasing and review and I expect this PR will make progress next week.

Copy link
Member

@abernix abernix left a comment

Choose a reason for hiding this comment

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

Looking good! I've left a couple comments/thoughts within.

Additionally, this should:

packages/apollo-engine-reporting/src/agent.ts Outdated Show resolved Hide resolved
packages/apollo-engine-reporting/src/extension.ts Outdated Show resolved Hide resolved
packages/apollo-engine-reporting/src/extension.ts Outdated Show resolved Hide resolved
packages/apollo-engine-reporting/src/extension.ts Outdated Show resolved Hide resolved
packages/apollo-engine-reporting/src/extension.ts Outdated Show resolved Hide resolved
@jsegaran jsegaran force-pushed the jsegaran/should_report_api branch 2 times, most recently from f36fcab to 1b07df0 Compare May 13, 2020 05:29
@jsegaran jsegaran changed the base branch from master to release-2.14.0 May 13, 2020 05:29
@jsegaran jsegaran force-pushed the jsegaran/should_report_api branch from 1b07df0 to 334d77e Compare May 15, 2020 00:44
@jsegaran jsegaran requested a review from abernix May 15, 2020 01:11
@jsegaran jsegaran force-pushed the jsegaran/should_report_api branch 2 times, most recently from e552ba9 to ce57d65 Compare May 15, 2020 01:38
@jsegaran jsegaran requested a review from glasser May 15, 2020 01:40
@abernix abernix dismissed their stale review May 15, 2020 10:53

I need to re-review.

Copy link
Member

@abernix abernix left a comment

Choose a reason for hiding this comment

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

Very excited for this to land! I'm thinking we'll get this into the 2.14.0 release, and I've left a few comments within that seem worth addressing.

Thanks for working on this! 🎉

packages/apollo-engine-reporting/src/agent.ts Outdated Show resolved Hide resolved
packages/apollo-engine-reporting/src/agent.ts Outdated Show resolved Hide resolved
packages/apollo-engine-reporting/src/plugin.ts Outdated Show resolved Hide resolved
packages/apollo-server-core/src/utils/pluginTestHarness.ts Outdated Show resolved Hide resolved
packages/apollo-server-core/src/utils/pluginTestHarness.ts Outdated Show resolved Hide resolved
packages/apollo-engine-reporting/src/plugin.ts Outdated Show resolved Hide resolved
packages/apollo-engine-reporting/src/plugin.ts Outdated Show resolved Hide resolved
packages/apollo-engine-reporting/src/plugin.ts Outdated Show resolved Hide resolved
packages/apollo-engine-reporting/src/plugin.ts Outdated Show resolved Hide resolved
@abernix abernix added this to the Release 2.14.0 milestone May 15, 2020
@jsegaran jsegaran force-pushed the jsegaran/should_report_api branch 3 times, most recently from 4b64147 to 66559c8 Compare May 18, 2020 02:15
@jsegaran jsegaran changed the base branch from release-2.14.0 to jsegaran/schema_reporting May 18, 2020 02:15
@jsegaran jsegaran requested a review from abernix May 18, 2020 02:16
@jsegaran
Copy link
Contributor Author

Thanks for the review. I rebased the PR off #4084 since I assume that will be merged first.

@abernix
Copy link
Member

abernix commented Jun 12, 2020

To match reportSchema from #4236, I'm voting for reportTrace.

@abernix
Copy link
Member

abernix commented Jun 12, 2020

Just noticed the commit that was pushed to this that switched to timeOperation.

Whatever decision is made, please update the title and description of the PR. 😄

@glasser
Copy link
Member

glasser commented Jun 12, 2020

I agree with Jesse that the PR desc needs to be updated and that it would make more sense for the name to be parallel with reportSchema but this is fine.

@jsegaran jsegaran changed the title feat(reporting): Add traceReporting option to EngineReportingOptions feat(reporting): Add reportTiming option to EngineReportingOptions Jun 12, 2020
renovate bot and others added 8 commits June 12, 2020 22:21
)

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Renovate Bot <bot@renovateapp.com>
@jsegaran
Copy link
Contributor Author

Updated the name to reportTiming and updated the pr description

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.

I didn't do a full rereview but assuming you consistently got the name changed I think this is still fine?

Copy link
Member

@abernix abernix left a comment

Choose a reason for hiding this comment

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

LGTM, though similarly to @glasser, I have not given it a full re-review though I've looked at it in the past. I'm going to retarget this to merge to release-2.15.0. Given the commits in this branch, is this a candidate for squashing?

@abernix abernix changed the base branch from master to release-2.15.0 June 16, 2020 12:24
@jsegaran
Copy link
Contributor Author

Yea I think squashing this seems good.

@jsegaran jsegaran merged commit 54ff1e6 into release-2.15.0 Jun 16, 2020
@abernix
Copy link
Member

abernix commented Jun 17, 2020

Shipped in 2.15.0!

abernix added a commit that referenced this pull request Jun 26, 2020
Previously, we were leveraging `sendReportsImmediately` to ... do exactly
that even though these tests don't need to send reports _at all_!.  This was
purely a hack to make sure that we don't need to wait for the Engine
Reporting Agent to eventually fail (after 5 seconds or whatever its
reporting interval is).

This new `reportTiming` option is available with the below-linked PR, so we
can now clean this up a bit.  This has the added advantage of not hitting
our actual reporting endpoint with an invalid API key, and having the logs
spew errors about failures in delivering those doomed reports.

Ref: #3918
abernix added a commit that referenced this pull request Jun 27, 2020
Previously, we were leveraging `sendReportsImmediately` to ... do exactly
that even though these tests don't need to send reports _at all_!.  This was
purely a hack to make sure that we don't need to wait for the Engine
Reporting Agent to eventually fail (after 5 seconds or whatever its
reporting interval is).

This new `reportTiming` option is available with the below-linked PR, so we
can now clean this up a bit.  This has the added advantage of not hitting
our actual reporting endpoint with an invalid API key, and having the logs
spew errors about failures in delivering those doomed reports.

Ref: #3918
abernix added a commit that referenced this pull request Jun 29, 2020
Previously, we were leveraging `sendReportsImmediately` to ... do exactly
that even though these tests don't need to send reports _at all_!.  This was
purely a hack to make sure that we don't need to wait for the Engine
Reporting Agent to eventually fail (after 5 seconds or whatever its
reporting interval is).

This new `reportTiming` option is available with the below-linked PR, so we
can now clean this up a bit.  This has the added advantage of not hitting
our actual reporting endpoint with an invalid API key, and having the logs
spew errors about failures in delivering those doomed reports.

Ref: #3918
@abernix abernix deleted the jsegaran/should_report_api branch February 5, 2021 06:58
@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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants