Skip to content

Update sentry library from raven-go to sentry-go

Markus Legner requested to merge mlegner/gitlab-runner:fix-sentry-go into main

What does this MR do?

This MR replaces the deprecated package raven-go by sentry-go for sentry integration. It essentially takes !2532 (closed) and adds unit tests and flushing for fatal errors.

Why was this MR needed?

The new format of Sentry DSNs is not supported by the current version of raven-go.

What's the best way to test this MR?

The MR includes unit tests to ensure that it works for DSNs in both the old and new format. Running the tests in the old implementation yields

$ go test ./helpers/sentry/...
--- FAIL: TestNewLogHook (0.00s)
    --- FAIL: TestNewLogHook/test_new_DSN_format_with_HTTP (0.00s)
        log_hook_test.go:33: NewLogHook() error = raven: dsn missing private key, wantErr false
    --- FAIL: TestNewLogHook/test_new_DSN_format_with_HTTPS (0.00s)
        log_hook_test.go:33: NewLogHook() error = raven: dsn missing private key, wantErr false
FAIL
FAIL    gitlab.com/gitlab-org/gitlab-runner/helpers/sentry      0.025s
FAIL

In the new version, it yields the expected

$ go test ./helpers/sentry/...
ok      gitlab.com/gitlab-org/gitlab-runner/helpers/sentry      0.008s

Further considerations

@steveazz suggested to simply use labkit/errortracking. Unfortunately, labkit currently doesn't support setting common tags as far as I can see, which gitlab-runner uses extensively (see helpers/sentry/log_hook.go#L51-60).

In my opinion, the following process would make sense:

  1. Merge this MR to immediately fix #4904 (closed)
  2. Add support for common tags in labkit/errortracking
  3. Create a separate MR here to switch to labkit/errortracking

What are the relevant issue numbers?

Closes #4904 (closed)

🛠 with at Siemens

Edited by Arran Walker

Merge request reports