Skip to content

Use the page name as identifier in Sentry tracing

Miguel Rincon requested to merge 339332-performance-transaction-name into master

What does this MR do and why?

Sentry tracks performance data by different "transactions" (pageload or navigation are considered a transaction). The transactions have an identifier to differenciate them. By default the transaction identifier is location.pathname.

location.pathname is not an appropriate identifier for GitLab, for example, the projects:pipelines:index page is recorded as two different endpoints when viewing different projects:

/gitlab-org/gitlab/-/pipelines/*
/gitlab-org/gitlab-ui/-/pipelines/*
Examples of transaction we record at the moment:

https://new-sentry.gitlab.net/organizations/gitlab/performance/?environment=gprd&project=4&statsPeriod=1h

image

GitLab has a data-page attribute in the <body> that can differentiate endpoints better than location.pathname. This change changes the identifier to be projects:pipelines:index for all the project pipeline pages: which is the way we want to track.

Screenshots or screen recordings

before after
before after-transaction

How to set up and validate locally

  1. Enable 2 feature flags:
    • Feature.enable(:enable_new_sentry_clientside_integration)
    • Feature.enable(:configure_sentry_in_application_settings).
  2. Testing on GDK requires disabling CSP on your browser (I temporarily used https://chrome.google.com/webstore/detail/disable-content-security/ieelmcmcagommplceebfedjlakkhpden, caution, don't keep this extension installed)
  3. Get the clientside DSN at https://new-sentry.gitlab.net/settings/gitlab/projects/gitlabcom-clientside/keys/, it looks like https://XXXX@new-sentry.gitlab.net/4
  4. Enable Sentry at Admin -> Metrics and profiling http://gdk.test:3000/admin/application_settings/metrics_and_profiling#js-sentry-settings, with the setting you see here, plus the DSN:
  5. We use a 1,0 in Clientside traces sample rate so our tracing report is always sent.
  6. Refresh the page, that should already send a request to Sentry.
  7. Verify the requests sent to Sentry: They should contain the correct transaction name. (this page happens to be admin:application_settings:metrics_and_profiling)
  8. Clean up! Disable Sentry in your local.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #339332 (closed)

Edited by Miguel Rincon

Merge request reports

Loading