Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

sentry: Heavily downsample presence spans.

Alex Vandiver6a3f97ba80ce
diff --git a/web/src/sentry.ts b/web/src/sentry.ts
index 8609de1740f..a08cd89fe4c 100644
--- a/web/src/sentry.ts
+++ b/web/src/sentry.ts
@@ -27,7 +27,7 @@ export function normalize_path(path: string, is_portico = false): string {
export function shouldCreateSpanForRequest(url: string): boolean {
const parsed = new URL(url, window.location.href);
- return !["/json/events", "/json/users/me/presence"].includes(parsed.pathname);
+ return parsed.pathname !== "/json/events";
}
if (page_params.server_sentry_dsn) {
@@ -64,6 +64,13 @@ if (page_params.server_sentry_dsn) {
}
}
+ const sample_rates = new Map([
+ // This is controlled by shouldCreateSpanForRequest, above, but also put here for consistency
+ ["call GET /json/events", 0],
+ // These requests are high-volume and do not add much data
+ ["call POST /json/users/me/presence", 0.01],
+ ]);
+
Sentry.init({
dsn: page_params.server_sentry_dsn,
environment: page_params.server_sentry_environment ?? "development",
@@ -86,7 +93,11 @@ if (page_params.server_sentry_dsn) {
],
allowUrls: url_matches,
sampleRate: page_params.server_sentry_sample_rate ?? 0,
- tracesSampleRate: page_params.server_sentry_trace_rate ?? 0,
+ tracesSampler(samplingContext) {
+ const base_rate = page_params.server_sentry_trace_rate ?? 0;
+ const name = samplingContext.transactionContext.name;
+ return base_rate * (sample_rates.get(name) ?? 1);
+ },
initialScope: {
tags: {
realm: sentry_key,