Skip to content

Commit 78c87e8

Browse files
authored
chore: Cleanup some unreachable code after v9 (#6599)
1 parent 837f5e4 commit 78c87e8

File tree

6 files changed

+31
-66
lines changed

6 files changed

+31
-66
lines changed

Sources/Sentry/Profiling/SentryLaunchProfiling.m

Lines changed: 31 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
NSString *const kSentryLaunchProfileConfigKeyTracesSampleRand = @"traces.sample_rand";
2929
NSString *const kSentryLaunchProfileConfigKeyProfilesSampleRate = @"profiles";
3030
NSString *const kSentryLaunchProfileConfigKeyProfilesSampleRand = @"profiles.sample_rand";
31-
NSString *const kSentryLaunchProfileConfigKeyContinuousProfilingV2
32-
= @"continuous-profiling-v2-enabled";
3331
NSString *const kSentryLaunchProfileConfigKeyContinuousProfilingV2Lifecycle
3432
= @"continuous-profiling-v2-lifecycle";
3533
NSString *const kSentryLaunchProfileConfigKeyWaitForFullDisplay
@@ -254,10 +252,6 @@
254252
NSDictionary<NSString *, NSNumber *> *persistedLaunchConfigOptionsDict
255253
= sentry_persistedLaunchProfileConfigurationOptions();
256254

257-
BOOL isContinuousV2 =
258-
[persistedLaunchConfigOptionsDict[kSentryLaunchProfileConfigKeyContinuousProfilingV2]
259-
boolValue];
260-
261255
SentrySamplerDecision *decision
262256
= _sentry_profileSampleDecision(persistedLaunchConfigOptionsDict);
263257
if (nil == decision) {
@@ -279,35 +273,29 @@
279273
BOOL shouldWaitForFullDisplay = shouldWaitForFullDisplayValue.boolValue;
280274

281275
SentryProfileOptions *profileOptions = nil;
282-
if (isContinuousV2) {
283-
SENTRY_LOG_DEBUG(@"Starting continuous launch profile v2.");
284-
NSNumber *lifecycleValue = persistedLaunchConfigOptionsDict
285-
[kSentryLaunchProfileConfigKeyContinuousProfilingV2Lifecycle];
286-
if (lifecycleValue == nil) {
287-
SENTRY_LOG_ERROR(
288-
@"Missing expected launch profile config parameter for lifecycle. Will "
289-
@"not proceed with launch profile.");
290-
_sentry_cleanUpConfigFile();
291-
return;
292-
}
293-
294-
profileOptions = [[SentryProfileOptions alloc] init];
276+
SENTRY_LOG_DEBUG(@"Starting continuous launch profile v2.");
277+
NSNumber *lifecycleValue = persistedLaunchConfigOptionsDict
278+
[kSentryLaunchProfileConfigKeyContinuousProfilingV2Lifecycle];
279+
if (lifecycleValue == nil) {
280+
SENTRY_LOG_ERROR(@"Missing expected launch profile config parameter for lifecycle. Will "
281+
@"not proceed with launch profile.");
282+
_sentry_cleanUpConfigFile();
283+
return;
284+
}
295285

296-
SentryProfileLifecycle lifecycle = lifecycleValue.intValue;
297-
if (lifecycle == SentryProfileLifecycleManual) {
298-
_sentry_continuousProfilingV2_startManualLaunchProfile(persistedLaunchConfigOptionsDict,
299-
profileOptions, decision, shouldWaitForFullDisplay);
300-
_sentry_cleanUpConfigFile();
301-
return;
302-
}
286+
profileOptions = [[SentryProfileOptions alloc] init];
303287

304-
_sentry_hydrateV2Options(persistedLaunchConfigOptionsDict, profileOptions, decision,
305-
SentryProfileLifecycleTrace, shouldWaitForFullDisplay);
306-
} else {
307-
sentry_profileConfiguration =
308-
[[SentryProfileConfiguration alloc] initWaitingForFullDisplay:shouldWaitForFullDisplay];
288+
SentryProfileLifecycle lifecycle = lifecycleValue.intValue;
289+
if (lifecycle == SentryProfileLifecycleManual) {
290+
_sentry_continuousProfilingV2_startManualLaunchProfile(
291+
persistedLaunchConfigOptionsDict, profileOptions, decision, shouldWaitForFullDisplay);
292+
_sentry_cleanUpConfigFile();
293+
return;
309294
}
310295

296+
_sentry_hydrateV2Options(persistedLaunchConfigOptionsDict, profileOptions, decision,
297+
SentryProfileLifecycleTrace, shouldWaitForFullDisplay);
298+
311299
// trace lifecycle UI profiling (continuous profiling v2) and trace-based profiling both join
312300
// paths here
313301
_sentry_startTraceProfiler(persistedLaunchConfigOptionsDict, decision);
@@ -333,22 +321,19 @@
333321
[NSMutableDictionary<NSString *, NSNumber *> dictionary];
334322
configDict[kSentryLaunchProfileConfigKeyWaitForFullDisplay] =
335323
@(options.enableTimeToFullDisplayTracing);
336-
if ([options isContinuousProfilingEnabled]) {
337-
SENTRY_LOG_DEBUG(@"Configuring continuous launch profile v2.");
338-
configDict[kSentryLaunchProfileConfigKeyContinuousProfilingV2] = @YES;
339-
configDict[kSentryLaunchProfileConfigKeyContinuousProfilingV2Lifecycle] =
340-
@(options.profiling.lifecycle);
341-
if (options.profiling.lifecycle == SentryProfileLifecycleTrace) {
342-
configDict[kSentryLaunchProfileConfigKeyTracesSampleRate]
343-
= config.tracesDecision.sampleRate;
344-
configDict[kSentryLaunchProfileConfigKeyTracesSampleRand]
345-
= config.tracesDecision.sampleRand;
346-
}
347-
configDict[kSentryLaunchProfileConfigKeyProfilesSampleRate]
348-
= config.profilesDecision.sampleRate;
349-
configDict[kSentryLaunchProfileConfigKeyProfilesSampleRand]
350-
= config.profilesDecision.sampleRand;
324+
SENTRY_LOG_DEBUG(@"Configuring continuous launch profile v2.");
325+
configDict[kSentryLaunchProfileConfigKeyContinuousProfilingV2Lifecycle] =
326+
@(options.profiling.lifecycle);
327+
if (options.profiling.lifecycle == SentryProfileLifecycleTrace) {
328+
configDict[kSentryLaunchProfileConfigKeyTracesSampleRate]
329+
= config.tracesDecision.sampleRate;
330+
configDict[kSentryLaunchProfileConfigKeyTracesSampleRand]
331+
= config.tracesDecision.sampleRand;
351332
}
333+
configDict[kSentryLaunchProfileConfigKeyProfilesSampleRate]
334+
= config.profilesDecision.sampleRate;
335+
configDict[kSentryLaunchProfileConfigKeyProfilesSampleRand]
336+
= config.profilesDecision.sampleRand;
352337
writeAppLaunchProfilingConfigFile(configDict);
353338
}];
354339
}

Sources/Sentry/include/SentryLaunchProfiling.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ SENTRY_EXTERN NSString *const kSentryLaunchProfileConfigKeyTracesSampleRate;
1818
SENTRY_EXTERN NSString *const kSentryLaunchProfileConfigKeyTracesSampleRand;
1919
SENTRY_EXTERN NSString *const kSentryLaunchProfileConfigKeyProfilesSampleRate;
2020
SENTRY_EXTERN NSString *const kSentryLaunchProfileConfigKeyProfilesSampleRand;
21-
SENTRY_EXTERN NSString *const kSentryLaunchProfileConfigKeyContinuousProfilingV2;
2221
SENTRY_EXTERN NSString *const kSentryLaunchProfileConfigKeyContinuousProfilingV2Lifecycle;
2322
SENTRY_EXTERN NSString *const kSentryLaunchProfileConfigKeyWaitForFullDisplay;
2423

Sources/Sentry/include/SentryProfileConfiguration.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ SENTRY_NO_INIT
3838
/** Initializer for SDK start if a configuration hasn't already been loaded for a launch profile. */
3939
- (instancetype)initWithProfileOptions:(SentryProfileOptions *)options;
4040

41-
/**
42-
* Initializer for both trace-based and continuous V1 (aka continuous beta) launch profiles.
43-
*/
44-
- (instancetype)initWaitingForFullDisplay:(BOOL)shouldWaitForFullDisplay;
45-
4641
/** Initializer for launch UI profiles (aka continuous V2). */
4742
- (instancetype)initContinuousProfilingV2WaitingForFullDisplay:(BOOL)shouldWaitForFullDisplay
4843
samplerDecision:(SentrySamplerDecision *)decision

Tests/SentryProfilerTests/SentryAppLaunchProfilingTests.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ extension SentryAppLaunchProfilingTests {
3939
// Assert
4040
XCTAssert(appLaunchProfileConfigFileExists())
4141
let dict = try XCTUnwrap(sentry_persistedLaunchProfileConfigurationOptions())
42-
XCTAssertEqual(try XCTUnwrap(dict[kSentryLaunchProfileConfigKeyContinuousProfilingV2]), true)
4342
XCTAssertEqual(try XCTUnwrap(dict[kSentryLaunchProfileConfigKeyProfilesSampleRate]), 1)
4443
XCTAssertEqual(try XCTUnwrap(dict[kSentryLaunchProfileConfigKeyProfilesSampleRand]), 0.5)
4544
XCTAssertEqual(try XCTUnwrap(dict[kSentryLaunchProfileConfigKeyTracesSampleRate]), 1)
@@ -71,7 +70,6 @@ extension SentryAppLaunchProfilingTests {
7170
// Assert
7271
XCTAssert(appLaunchProfileConfigFileExists())
7372
let dict = try XCTUnwrap(sentry_persistedLaunchProfileConfigurationOptions())
74-
XCTAssertEqual(try XCTUnwrap(dict[kSentryLaunchProfileConfigKeyContinuousProfilingV2]), true)
7573
XCTAssertEqual(try XCTUnwrap(dict[kSentryLaunchProfileConfigKeyProfilesSampleRate]), 1)
7674
XCTAssertEqual(try XCTUnwrap(dict[kSentryLaunchProfileConfigKeyProfilesSampleRand]), 0.5)
7775
XCTAssertNil(dict[kSentryLaunchProfileConfigKeyTracesSampleRate])

Tests/SentryProfilerTests/SentryAppStartProfilingConfigurationChangeTests.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ extension SentryAppStartProfilingConfigurationChangeTests {
2828
// Arrange
2929
// persisted configuration simulating previous launch
3030
let configDict: [String: Any] = [
31-
kSentryLaunchProfileConfigKeyContinuousProfilingV2: true,
3231
kSentryLaunchProfileConfigKeyContinuousProfilingV2Lifecycle: SentryProfileLifecycle.manual.rawValue,
3332
kSentryLaunchProfileConfigKeyProfilesSampleRate: 0.5,
3433
kSentryLaunchProfileConfigKeyProfilesSampleRand: 0.5,
@@ -70,7 +69,6 @@ extension SentryAppStartProfilingConfigurationChangeTests {
7069
// Arrange
7170
// persisted configuration simulating previous launch
7271
let configDict: [String: Any] = [
73-
kSentryLaunchProfileConfigKeyContinuousProfilingV2: true,
7472
kSentryLaunchProfileConfigKeyContinuousProfilingV2Lifecycle: SentryProfileLifecycle.manual.rawValue,
7573
kSentryLaunchProfileConfigKeyProfilesSampleRate: 0.5,
7674
kSentryLaunchProfileConfigKeyProfilesSampleRand: 0.5,
@@ -112,7 +110,6 @@ extension SentryAppStartProfilingConfigurationChangeTests {
112110
// Arrange
113111
// persisted configuration simulating previous launch
114112
let configDict: [String: Any] = [
115-
kSentryLaunchProfileConfigKeyContinuousProfilingV2: true,
116113
kSentryLaunchProfileConfigKeyContinuousProfilingV2Lifecycle: SentryProfileLifecycle.trace.rawValue,
117114
kSentryLaunchProfileConfigKeyProfilesSampleRate: 0.5,
118115
kSentryLaunchProfileConfigKeyProfilesSampleRand: 0.5,
@@ -155,7 +152,6 @@ extension SentryAppStartProfilingConfigurationChangeTests {
155152
// Arrange
156153
// persisted configuration simulating previous launch
157154
let configDict: [String: Any] = [
158-
kSentryLaunchProfileConfigKeyContinuousProfilingV2: true,
159155
kSentryLaunchProfileConfigKeyContinuousProfilingV2Lifecycle: SentryProfileLifecycle.trace.rawValue,
160156
kSentryLaunchProfileConfigKeyProfilesSampleRate: 0.5,
161157
kSentryLaunchProfileConfigKeyProfilesSampleRand: 0.5,
@@ -202,7 +198,6 @@ extension SentryAppStartProfilingConfigurationChangeTests {
202198
// Arrange
203199
// persisted configuration simulating previous launch
204200
let configDict: [String: Any] = [
205-
kSentryLaunchProfileConfigKeyContinuousProfilingV2: true,
206201
kSentryLaunchProfileConfigKeyContinuousProfilingV2Lifecycle: SentryProfileLifecycle.manual.rawValue,
207202
kSentryLaunchProfileConfigKeyProfilesSampleRate: 0.5,
208203
kSentryLaunchProfileConfigKeyProfilesSampleRand: 0.5,
@@ -244,7 +239,6 @@ extension SentryAppStartProfilingConfigurationChangeTests {
244239
// Arrange
245240
// persisted configuration simulating previous launch
246241
let configDict: [String: Any] = [
247-
kSentryLaunchProfileConfigKeyContinuousProfilingV2: true,
248242
kSentryLaunchProfileConfigKeyContinuousProfilingV2Lifecycle: SentryProfileLifecycle.manual.rawValue,
249243
kSentryLaunchProfileConfigKeyProfilesSampleRate: 0.5,
250244
kSentryLaunchProfileConfigKeyProfilesSampleRand: 0.5,
@@ -286,7 +280,6 @@ extension SentryAppStartProfilingConfigurationChangeTests {
286280
// Arrange
287281
// persisted configuration simulating previous launch
288282
let configDict: [String: Any] = [
289-
kSentryLaunchProfileConfigKeyContinuousProfilingV2: true,
290283
kSentryLaunchProfileConfigKeyContinuousProfilingV2Lifecycle: SentryProfileLifecycle.trace.rawValue,
291284
kSentryLaunchProfileConfigKeyProfilesSampleRate: 0.5,
292285
kSentryLaunchProfileConfigKeyProfilesSampleRand: 0.5,
@@ -335,7 +328,6 @@ extension SentryAppStartProfilingConfigurationChangeTests {
335328
// Arrange
336329
// persisted configuration simulating previous launch
337330
let configDict: [String: Any] = [
338-
kSentryLaunchProfileConfigKeyContinuousProfilingV2: true,
339331
kSentryLaunchProfileConfigKeyContinuousProfilingV2Lifecycle: SentryProfileLifecycle.trace.rawValue,
340332
kSentryLaunchProfileConfigKeyProfilesSampleRate: 0.5,
341333
kSentryLaunchProfileConfigKeyProfilesSampleRand: 0.5,

Tests/SentryProfilerTests/SentryApplaunchProfilingMalformedConfigFileTests.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ class SentryAppLaunchProfilingMalformedConfigFileTests: XCTestCase {
3535
func testMalformedConfigFile_ContinuousV2MissingLifecycle_DoesNotStartProfilingAndRemovesFile() throws {
3636
// Create a config file with continuous profiling v2 enabled but missing lifecycle
3737
let configDict: [String: Any] = [
38-
kSentryLaunchProfileConfigKeyContinuousProfilingV2: true,
3938
kSentryLaunchProfileConfigKeyProfilesSampleRate: 1.0,
4039
kSentryLaunchProfileConfigKeyProfilesSampleRand: 0.5
4140
// Missing: kSentryLaunchProfileConfigKeyContinuousProfilingV2Lifecycle
@@ -59,7 +58,6 @@ class SentryAppLaunchProfilingMalformedConfigFileTests: XCTestCase {
5958
func testMalformedConfigFile_ContinuousV2ManualMissingSampleRate_DoesNotStartProfilingAndRemovesFile() throws {
6059
// Create a config file with continuous profiling v2 manual lifecycle but missing sample rate
6160
let configDict: [String: Any] = [
62-
kSentryLaunchProfileConfigKeyContinuousProfilingV2: true,
6361
kSentryLaunchProfileConfigKeyContinuousProfilingV2Lifecycle: SentryProfileLifecycle.manual.rawValue,
6462
kSentryLaunchProfileConfigKeyProfilesSampleRand: 0.5
6563
// Missing: kSentryLaunchProfileConfigKeyProfilesSampleRate
@@ -83,7 +81,6 @@ class SentryAppLaunchProfilingMalformedConfigFileTests: XCTestCase {
8381
func testMalformedConfigFile_ContinuousV2ManualMissingSampleRand_DoesNotStartProfilingAndRemovesFile() throws {
8482
// Create a config file with continuous profiling v2 manual lifecycle but missing sample rand
8583
let configDict: [String: Any] = [
86-
kSentryLaunchProfileConfigKeyContinuousProfilingV2: true,
8784
kSentryLaunchProfileConfigKeyContinuousProfilingV2Lifecycle: SentryProfileLifecycle.manual.rawValue,
8885
kSentryLaunchProfileConfigKeyProfilesSampleRate: 1.0
8986
// Missing: kSentryLaunchProfileConfigKeyProfilesSampleRand
@@ -222,7 +219,6 @@ class SentryAppLaunchProfilingMalformedConfigFileTests: XCTestCase {
222219
func testMalformedConfigFile_ContinuousV2TraceLifecycleMissingTracesRate_DoesNotStartProfilingAndRemovesFile() throws {
223220
// Create a config file with continuous profiling v2 trace lifecycle but missing traces sample rate
224221
let configDict: [String: Any] = [
225-
kSentryLaunchProfileConfigKeyContinuousProfilingV2: true,
226222
kSentryLaunchProfileConfigKeyContinuousProfilingV2Lifecycle: SentryProfileLifecycle.trace.rawValue,
227223
kSentryLaunchProfileConfigKeyProfilesSampleRate: 1.0,
228224
kSentryLaunchProfileConfigKeyProfilesSampleRand: 0.5,

0 commit comments

Comments
 (0)