From f7caa8d7f6dd1fb3136012f81e472f91e8fd8a81 Mon Sep 17 00:00:00 2001 From: Hubert Sosinski Date: Mon, 16 Mar 2026 11:20:57 +0100 Subject: [PATCH 1/2] sentry debug spans to be displayed only locally --- src/libs/telemetry/activeSpans.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/libs/telemetry/activeSpans.ts b/src/libs/telemetry/activeSpans.ts index 84af93aa09fcd..1a1e0387d316c 100644 --- a/src/libs/telemetry/activeSpans.ts +++ b/src/libs/telemetry/activeSpans.ts @@ -1,7 +1,6 @@ import type {SpanAttributeValue, StartSpanOptions} from '@sentry/core'; import * as Sentry from '@sentry/react-native'; import {AppState} from 'react-native'; -import Log from '@libs/Log'; import CONST from '@src/CONST'; type ActiveSpanEntry = { @@ -25,7 +24,7 @@ function startSpan(spanId: string, options: StartSpanOptions, extraOptions: Star } // End any existing span for this name cancelSpan(spanId); - Log.info(`[Sentry][${spanId}] Starting span`, undefined, { + console.debug(`[Sentry][${spanId}] Starting span`, { spanId, spanOptions: options, spanExtraOptions: extraOptions, @@ -45,13 +44,13 @@ function endSpan(spanId: string) { const entry = activeSpans.get(spanId); if (!entry) { - Log.info(`[Sentry][${spanId}] Trying to end span but it does not exist`, undefined, {spanId, timestamp: Date.now()}); + console.debug(`[Sentry][${spanId}] Trying to end span but it does not exist`, {spanId, timestamp: Date.now()}); return; } const {span, startTime} = entry; const now = performance.now(); const durationMs = Math.round(now - startTime); - Log.info(`[Sentry][${spanId}] Ending span (${durationMs}ms)`, undefined, {spanId, durationMs, timestamp: now}); + console.debug(`[Sentry][${spanId}] Ending span (${durationMs}ms)`, {spanId, durationMs, timestamp: now}); span.setStatus({code: 1}); span.setAttribute(CONST.TELEMETRY.ATTRIBUTE_FINISHED_MANUALLY, true); span.end(); @@ -63,7 +62,7 @@ function cancelSpan(spanId: string) { if (!entry) { return; } - Log.info(`[Sentry][${spanId}] Canceling span`, undefined, {spanId, timestamp: Date.now()}); + console.debug(`[Sentry][${spanId}] Canceling span`, {spanId, timestamp: Date.now()}); entry.span.setAttribute(CONST.TELEMETRY.ATTRIBUTE_CANCELED, true); // In Sentry there are only OK or ERROR status codes. // We treat canceled spans as OK, so we can properly track spans that are not finished at all (their status would be different) From 90354c0c8ce5037d769f32c3df6d77123cbab4fa Mon Sep 17 00:00:00 2001 From: Hubert Sosinski Date: Mon, 16 Mar 2026 11:28:40 +0100 Subject: [PATCH 2/2] remove tryEndSpan as it's purpose is no more needed. No `/api/Log` for Sentry spans are sent --- src/libs/telemetry/activeSpans.ts | 15 +-------------- .../inbox/report/comment/TextCommentFragment.tsx | 4 ++-- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/libs/telemetry/activeSpans.ts b/src/libs/telemetry/activeSpans.ts index 1a1e0387d316c..7bf4e47a6942e 100644 --- a/src/libs/telemetry/activeSpans.ts +++ b/src/libs/telemetry/activeSpans.ts @@ -84,19 +84,6 @@ function cancelSpansByPrefix(prefix: string) { } } -/** - * Ends a span only if it's currently active. Unlike `endSpan`, this silently no-ops - * when the span doesn't exist, making it safe for render paths where the span - * may or may not have been started. - */ -function tryEndSpan(spanId: string): boolean { - if (!activeSpans.has(spanId)) { - return false; - } - endSpan(spanId); - return true; -} - function getSpan(spanId: string) { return activeSpans.get(spanId)?.span; } @@ -107,4 +94,4 @@ function endSpanWithAttributes(spanId: string, attributes: Record tags and emoji tag