doc/operations/integrated_error_tracking.md
{{< details >}}
{{< /details >}}
This guide provides basic information on how to set up integrated error tracking for your project, using examples from different languages.
Error tracking provided by GitLab Observability is based on Sentry SDK. For more information and examples of how you can use Sentry SDK in your application, see the Sentry SDK documentation.
Regardless of the programming language you use, you first need to enable error tracking
for your GitLab project. This guide uses the GitLab.com instance.
Prerequisites:
To enable error tracking with GitLab as the backend:
To track the number of users affected by an error:
For example, if you use Python, you can identify a user by email:
sentry_sdk.set_user({ email: "[email protected]" });
For more information about user identification, see the Sentry documentation.
After your application emits errors to the Error Tracking API through the Sentry SDK, those errors are available in the GitLab UI. To view them:
In the top bar, select Search or go to and find your project.
Go to Monitor > Error Tracking to see the list of open errors:
Select an error to see the Error details view:
This page shows more details of the exception, including:
If you want to track work related to an error, you can create an issue directly from the error:
An issue is created. The issue description contains the error stack trace.
To view the full timestamp of an error:
In the following example, the error happened at 11:41 CEST:
The Last 24 hours graph measures how many times this error occurred per hour.
By pointing at the 11 am bar, the dialog shows the error was seen 239 times:
The Last seen field does not update until the full hour is complete, due to
the library used for the call
import * as timeago from 'timeago.js'.
GitLab Error Tracking supports these event types:
| Language | Tested SDK client and version | Endpoint | Supported item types |
|---|---|---|---|
| Go | sentry-go/0.20.0 | store | exception, message |
| Java | sentry.java:6.18.1 | envelope | exception, message |
| NodeJS | sentry.javascript.node:7.38.0 | envelope | exception, message |
| PHP | sentry.php/3.18.0 | store | exception, message |
| Python | sentry.python/1.21.0 | envelope | exception, message, session |
| Ruby | sentry.ruby:5.9.0 | envelope | exception, message |
| Rust | sentry.rust/0.31.0 | envelope | exception, message, session |
For a detailed version of this table, see issue 1737.
See also working examples for supported language SDKs, showing how to capture exceptions, events, or messages with that SDK. For more information, see the Sentry SDK documentation for a specific language.
[!warning] According to Sentry it is safe to keep a DSN public, but this opens up the possibility of junk events being sent to Sentry by malicious users. Therefore if possible you should keep the DSN secret. This doesn't apply to client-side applications where the DSN will be loaded and therefore stored on the user's device.
Prerequisites:
To rotate the Sentry DSN:
Create an access token
with the api scope. Copy off this value, as you need it in future steps.
Use the error tracking API to create a new Sentry DSN,
replacing <your_access_token> and <your_project_number> with your values:
curl --request POST \
--header "PRIVATE-TOKEN: <your_access_token>" \
--header "Content-Type: application/json" \
--url "https://gitlab.example.com/api/v4/projects/<your_project_number>/error_tracking/client_keys"
Get the available client keys (Sentry DSNs). Ensure your newly-created Sentry DSN
is in place. Run the following command with the key ID of the old client key, replacing <your_access_token>
and <your_project_number> with your values:
curl --header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/projects/<your_project_number>/error_tracking/client_keys"
Delete the old client key:
curl --request DELETE \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/projects/<your_project_number>/error_tracking/client_keys/<key_id>"
The majority of languages supported by Sentry expose a debug option as part
of initialization. The debug option can help you when you debug issues with
sending errors. Other options exist to output JSON before sending the data to the API.
GitLab has a 90-day retention limit for all errors.
To leave feedback about Error Tracking bugs or features, comment in the feedback issue or open a new issue.