Skip to content

Resolve "Add a GraphQL query for Error Tracking - List Errors"

Sean Arnold requested to merge 35897-grapghql-error-tracking-list-errors into master

What does this MR do?

This adds the ability to retrieve Sentry Errors for a given Project.

It is intended to eventually replace the REST endpoint GET /*namespace_id/:project_id/-/error_tracking

Background We call Sentry's API in order to get the error details so we can display them inside GitLab. Sentry implements their own pagination in their APIs and so we need to fit within their limitations when it comes to returning results.

Sentry returns 20 results per page, and provides a cursor for the next and previous page (if valid). It doesn't appear from my investigation that we have any way of inferring a cursor value for each item returned and so we can only return the cursors that Sentry returns us. (The previous page and next page cursors).

Implementation

To keep returning the GraphQL pagination format we are using GitLab::Graphql::Connections::ExternalArrayConnection, which was added in !22200 (merged).

I created a wrapper type Types::ErrorTracking::SentryErrorCollectionType. This is used to either query for the errors, or an individual detailed_error (detailed errors were made in !19733 (merged)), as well as the external URL of Sentry.

I created a custom ConnectionExtension (https://graphql-ruby.org/api-doc/1.9.16/GraphQL/Schema/Field/ConnectionExtension), Types::ErrorTracking::SentryErrorExtension, in order to use the Pagination arguments when resolving the data as I need to send them to Sentry in order to paginate.

Example use: An example request sequence from the frontend might look like:

Fetching errors:

{
  project(fullPath: "root/monitor-sandbox") {
    sentryErrors {
      errors(after:"1576029072000:0:0") {
        nodes {
          id
          title
          culprit
        }
        pageInfo {
          hasNextPage
          endCursor
        }
      }
      externalUrl
    }
  }
}

<user clicks on an error, now to fetch the detaliled error>:

{
  project(fullPath: "root/monitor-sandbox") {
    sentryErrors {
      detailedError(id: "gid://gitlab/Gitlab::ErrorTracking::Error/1381945331") {
        title
        lastReleaseLastCommit
        etc..
      }
    }
  }
}

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Closes #35897 (closed)

Edited by Sean Arnold

Merge request reports