Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

DEVPROD-356: Add Sentry grouping #2262

Merged
merged 4 commits into from
Feb 20, 2024
Merged

Conversation

sophstad
Copy link
Contributor

@sophstad sophstad commented Feb 15, 2024

DEVPROD-356

Description

Added two new fields to GraphQL errors that should help with grouping in the app:

  • Adding a fingerprint based on the operation name should force these errors to be grouped together. I've also appended the path to the fingerprint, which means that errors will only be grouped if the same field was the cause of the error. This is a little bit more aggressive than just grouping on operation name, but I think it will be helpful
  • Adding operation name as a tag allows it to be searchable.

Testing

  • The event grouping information for this event shows the custom fingerprint in use.
  • Clicking "All Events" at the top of that page allows you to see all errors that were thrown by UserProjectSettingsPermissions being thrown with an error in the project identifier.
  • operationName is now a tag appearing at the top of the page:
    image

I think this is a pretty logical way of grouping things. You can also take a look on staging and see how incoming errors are grouped. Sentry's "recommended error" view is still confusing to me, and the error titles are still somewhat useless, but I think the grouping is improved.

Copy link

cypress bot commented Feb 15, 2024

3 flaky tests on run #15784 ↗︎

0 545 10 0 Flakiness 3
⚠️ You've recorded test results over your free plan limit.
Upgrade your plan to view test results.

Details:

Improve fingerprint/tag handling
Project: Spruce Commit: eb7335b311
Status: Passed Duration: 19:21 💡
Started: Feb 16, 2024 9:33 PM Ended: Feb 16, 2024 9:52 PM

Review all test suite changes for PR #2262 ↗︎

@sophstad sophstad requested a review from a team February 15, 2024 18:28
Copy link
Contributor

@khelif96 khelif96 left a comment

Choose a reason for hiding this comment

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

Great job investigating this! I just had a few comments but it looks great to me and I'm excited to see how it looks in production

@@ -46,6 +47,21 @@ const sendError = (
withScope((scope) => {
setScope(scope, { level: severity, context: metadata });

const { gqlErr, operationName } = metadata ?? {};
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we improve the type safety on these by adding gqlErr and operationName as option fields in the metadata struct on line 46.

scope.setFingerprint(fingerprint);

// Apply tag, which is a searchable/filterable property
setTag("operationName", metadata.operationName);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
setTag("operationName", metadata.operationName);
setTag("operationName", operationName);

@khelif96
Copy link
Contributor

Can we also make these changes in parsley

const sendError = (
err: Error,
severity: SeverityLevel,
metadata?: { [key: string]: any },
metadata?: ErrorMetadata,
Copy link
Contributor

Choose a reason for hiding this comment

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

This typing is technically broken since

const reportError = (
passes a generic { [key:string]: any } so this type is never actually used.

Copy link
Contributor

Choose a reason for hiding this comment

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

It is also not flexible enough to allow for any metadata to be passed in once the typing in reportError is fixed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the typing in errorReporting.ts. If you want strict typing I think we should just go all the way and update this type as more metadata fields are added rather than allow the type to be flexible.

Comment on lines 44 to 46
gqlErr?: ErrorResponse["graphQLErrors"][0];
operationName?: ErrorResponse["operation"]["operationName"];
variables?: ErrorResponse["operation"]["variables"];
Copy link
Contributor

Choose a reason for hiding this comment

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

These are all actually typed from
import { GraphQLError } from "graphql"; since they are properties of the GraphQL request and not specific to Apollo.

Copy link
Contributor Author

@sophstad sophstad Feb 16, 2024

Choose a reason for hiding this comment

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

This is the correct typing of Apollo's onError handlers if I'm not mistaken: https://github.com/apollographql/apollo-client/blob/17ccc42825d0b0355212f3ac823780edb467ea77/src/link/error/index.ts#L28

GraphQLError doesn't include operationName or variables: https://github.com/graphql/graphql-js/blob/9c90a23dd430ba7b9db3d566b084e9f66aded346/src/error/GraphQLError.ts#L41

These are Apollo-specific since they come from Apollo links; the GraphQL request is just a part of the data in the graphQLErrors field.

@sophstad sophstad requested a review from khelif96 February 16, 2024 18:26
Copy link
Contributor

@khelif96 khelif96 left a comment

Choose a reason for hiding this comment

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

We discussed offline and we will make this more generic to support general grouping in the future. Feel free to re-request a review when you are ready @sophstad

Copy link
Contributor

@khelif96 khelif96 left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@sophstad sophstad merged commit 304de82 into evergreen-ci:main Feb 20, 2024
5 of 6 checks passed
@sophstad sophstad deleted the DEVPROD-356 branch February 20, 2024 15:35
@khelif96
Copy link
Contributor

Can we do this on Parsley as well please! @sophstad

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