Skip to content

Spike: GDK seeding fixture for error tracking

Investigate what it would take for us to seed error tracking fixture so that we can schedule/create a plan to implement #697

Conclusion

Seeding a Sentry instance during a GDK setup automatically is feasible. Almost all of the actions below can be automated. Manual steps are marked with

The following list tries to illustrate what steps are needed to preconfigure Sentry and seed a project in a GDK instance.

Sentry installation

We'd use the suggested method to install non-interactively Sentry via a docker compose.

git clone https://github.com/getsentry/onpremise.git

cd onpremise

# non-interactive installation
CI=1 ./install.sh

docker-compose up -d

Setup admin user & API token

We need to create the admin user (which was skipped due to non-interactive installation above) and an API token.

cd onpremise

docker-compose run --rm web createuser --email root@example.com --password '5iveL!fe' --superuser

We'd create the API token using psql.

docker-compose exec postgres psql -U postgres
postgres=#
INSERT INTO sentry_apitoken
(
   scopes,
   scope_list,
   token,
   date_added,
   user_id
)
SELECT
   0,
   '{event:write,project:write}',
   md5(now()::varchar),
   now(),
   id
FROM
  sentry_useremail
WHERE
  email = 'root@example.com'
;

Create and setup project in Sentry

This has to be done manually using Sentry's UI (http://127.0.0.1:9000/organizations/sentry/projects/new/).

I couldn't find an endpoint in Projects API which creates a project. 😟

Enable Sentry in config/gitlab.yml

Configure GDK to use the installed Sentry instance.

We'll retrieve the dsn values via psql:

docker-compose exec postgres psql -U postgres
postgres=#
SELECT public_key, secret_key WHERE project_id = 2;

These values we can use in config/gitlab.yml to connect GitLab to Sentry:

production: &base

  ...

  sentry:
    enabled: true
    dsn: 'http://PUBLIC_KEY:SECRET_KEY@127.0.0.1:9000/2'
    environment: 'development'

Setup project in GDK

Now, we could seed a GitLab project (e.g via db/fixtures/development/03_project) called GitLab and setup "Error Tracking" automatically:

project = Project.find_by_full_path("root/GitLab")
project.build_error_tracking_setting!(
  api_url: "http://127.0.0.1:9000/api/0/projects/sentry/internal/",
  token: SENTRY_ADMIN_TOKEN,
  enabled: true,
  project_name: "GitLab",
  organization_name: "Sentry"
)

In order to create exceptions which are tracked by Sentry and displayed in GitLab we could enhance GitLab's Chaos controller by some actions which generate Sentry-tracked exceptions. We can link these "chaos actions" in the "GitLab" project's README.md for easier access.

Not sure we can trigger some of these actions automatically during seeding the project.

Shared Sentry instance

Alternatively, we could also create one Sentry instance shared by several developers. This setup would require developers to expose their private IP using a tunnel or similar.

Edited by Peter Leitzen