♻️(front) use sentry tags instead of extra scope

To ease filtering issues on sentry, we want to use tags instead of extra
scope. Tags are indexed and searchable, it's not the case with extra
scope. Moreover using setEtra to add additional data is deprecated.
This commit is contained in:
Manuel Raynaud
2025-03-04 17:19:53 +01:00
parent b9b5f86cf4
commit ebf6d46e37
4 changed files with 22 additions and 14 deletions

View File

@@ -8,6 +8,10 @@ and this project adheres to
## [Unreleased]
## Changed
- Use sentry tags instead of extra scope
## [2.3.0] - 2025-03-03
## Added

View File

@@ -19,6 +19,7 @@ from django.utils.translation import gettext_lazy as _
import sentry_sdk
from configurations import Configuration, values
from sentry_sdk.integrations.django import DjangoIntegration
from sentry_sdk.integrations.logging import ignore_logger
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@@ -646,8 +647,10 @@ class Base(Configuration):
release=get_release(),
integrations=[DjangoIntegration()],
)
with sentry_sdk.configure_scope() as scope:
scope.set_extra("application", "backend")
sentry_sdk.set_tag("application", "backend")
# Ignore the logs added by the DockerflowMiddleware
ignore_logger("request.summary")
if (
cls.OIDC_FALLBACK_TO_EMAIL_FOR_IDENTIFICATION

View File

@@ -12,21 +12,21 @@ interface SentryState {
export const useSentryStore = create<SentryState>((set, get) => ({
sentry: undefined,
setSentry: (dsn, environment) => {
const sentry = get().sentry;
if (sentry) {
if (get().sentry) {
return;
}
set({
sentry: Sentry.init({
dsn,
environment,
integrations: [Sentry.replayIntegration()],
release: packageJson.version,
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
tracesSampleRate: 0.1,
}),
const sentry = Sentry.init({
dsn,
environment,
integrations: [Sentry.replayIntegration()],
release: packageJson.version,
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
tracesSampleRate: 0.1,
});
Sentry.setTag('application', 'frontend');
set({ sentry });
},
}));

View File

@@ -9,3 +9,4 @@ Sentry.init({
tracesSampleRate: 0.1,
profilesSampleRate: 1.0,
});
Sentry.setTag('application', 'y-provider');