From 20dcfc83f289387efca4fb5d7b3b94d1b343ea46 Mon Sep 17 00:00:00 2001 From: Nikolay Edigaryev Date: Mon, 10 Nov 2025 23:50:32 +0400 Subject: [PATCH] Disable Sentry's app launch profiling (#1164) And access SentrySDK only when SENTRY_DSN is set. --- Sources/tart/Root.swift | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/Sources/tart/Root.swift b/Sources/tart/Root.swift index 477e6f9..9d98a12 100644 --- a/Sources/tart/Root.swift +++ b/Sources/tart/Root.swift @@ -70,20 +70,30 @@ struct Root: AsyncParsableCommand { HttpStatusCodeRange(min: 400, max: 400), HttpStatusCodeRange(min: 402, max: 599) ] + + // https://github.com/cirruslabs/tart/issues/1163 + options.enableAppLaunchProfiling = false + options.configureProfiling = { + $0.profileAppStarts = false + } + } + + SentrySDK.configureScope { scope in + scope.setExtra(value: ProcessInfo.processInfo.arguments, key: "Command-line arguments") + } + + // Enrich future events with Cirrus CI-specific tags + if let tags = ProcessInfo.processInfo.environment["CIRRUS_SENTRY_TAGS"] { + SentrySDK.configureScope { scope in + for (key, value) in tags.split(separator: ",").compactMap({ parseCirrusSentryTag($0) }) { + scope.setTag(value: value, key: key) + } + } } } - defer { SentrySDK.flush(timeout: 2.seconds.timeInterval) } - - SentrySDK.configureScope { scope in - scope.setExtra(value: ProcessInfo.processInfo.arguments, key: "Command-line arguments") - } - - // Enrich future events with Cirrus CI-specific tags - if let tags = ProcessInfo.processInfo.environment["CIRRUS_SENTRY_TAGS"] { - SentrySDK.configureScope { scope in - for (key, value) in tags.split(separator: ",").compactMap({ parseCirrusSentryTag($0) }) { - scope.setTag(value: value, key: key) - } + defer { + if ProcessInfo.processInfo.environment["SENTRY_DSN"] != nil { + SentrySDK.flush(timeout: 2.seconds.timeInterval) } } @@ -109,8 +119,10 @@ struct Root: AsyncParsableCommand { } // Capture the error into Sentry - SentrySDK.capture(error: error) - SentrySDK.flush(timeout: 2.seconds.timeInterval) + if ProcessInfo.processInfo.environment["SENTRY_DSN"] != nil { + SentrySDK.capture(error: error) + SentrySDK.flush(timeout: 2.seconds.timeInterval) + } // Handle a non-ArgumentParser's exception that requires a specific exit code to be set if let errorWithExitCode = error as? HasExitCode {