Skip to content

Commit 5292991

Browse files
committed
feat(v9): Remove profiling APIs deprecated in V9
1 parent 736bcfb commit 5292991

File tree

14 files changed

+110
-36
lines changed

14 files changed

+110
-36
lines changed

Samples/iOS-ObjectiveC/iOS-ObjectiveC/AppDelegate.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ - (BOOL)application:(UIApplication *)application
5151
};
5252
}
5353

54+
#if !SDK_V9
5455
if (env[@"--io.sentry.profiling.profilesSampleRate"] != nil) {
5556
options.profilesSampleRate =
5657
@([env[@"--io.sentry.profiling.profilesSampleRate"] floatValue]);
@@ -67,6 +68,7 @@ - (BOOL)application:(UIApplication *)application
6768
if (![args containsObject:@"--io.sentry.profiling.disable-app-start-profiling"]) {
6869
options.enableAppLaunchProfiling = YES;
6970
}
71+
#endif // !SDK_V9
7072

7173
SentryHttpStatusCodeRange *httpStatusCodeRange =
7274
[[SentryHttpStatusCodeRange alloc] initWithMin:400 max:599];

Sources/Sentry/Profiling/SentryLaunchProfiling.m

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
NSString *const kSentryLaunchProfileConfigKeyTracesSampleRand = @"traces.sample_rand";
3030
NSString *const kSentryLaunchProfileConfigKeyProfilesSampleRate = @"profiles";
3131
NSString *const kSentryLaunchProfileConfigKeyProfilesSampleRand = @"profiles.sample_rand";
32+
# if !SDK_V9
3233
NSString *const kSentryLaunchProfileConfigKeyContinuousProfiling = @"continuous-profiling";
34+
# endif // !SDK_V9
3335
NSString *const kSentryLaunchProfileConfigKeyContinuousProfilingV2
3436
= @"continuous-profiling-v2-enabled";
3537
NSString *const kSentryLaunchProfileConfigKeyContinuousProfilingV2Lifecycle
@@ -63,11 +65,12 @@
6365
SentrySamplerDecision *_Nullable profilesDecision;
6466
} SentryLaunchProfileConfig;
6567

68+
# if !SDK_V9
6669
SentryLaunchProfileConfig
6770
sentry_launchShouldHaveTransactionProfiling(SentryOptions *options)
6871
{
69-
# pragma clang diagnostic push
70-
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
72+
# pragma clang diagnostic push
73+
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
7174
BOOL shouldProfileNextLaunch = options.enableAppLaunchProfiling && options.enableTracing;
7275
if (!shouldProfileNextLaunch) {
7376
SENTRY_LOG_DEBUG(@"Specified options configuration doesn't enable launch profiling: "
@@ -76,7 +79,7 @@
7679
options.enableAppLaunchProfiling, options.enableTracing);
7780
return (SentryLaunchProfileConfig) { NO, nil, nil };
7881
}
79-
# pragma clang diagnostic pop
82+
# pragma clang diagnostic pop
8083

8184
SentryTransactionContext *transactionContext =
8285
[[SentryTransactionContext alloc] initWithName:@"app.launch" operation:@"profile"];
@@ -101,6 +104,7 @@
101104
SENTRY_LOG_DEBUG(@"Will start transaction profile next launch; will profile launch.");
102105
return (SentryLaunchProfileConfig) { YES, tracesSamplerDecision, profilesSamplerDecision };
103106
}
107+
# endif // !SDK_V9
104108

105109
SentryLaunchProfileConfig
106110
sentry_launchShouldHaveContinuousProfilingV2(SentryOptions *options)
@@ -163,15 +167,19 @@
163167
if ([options isContinuousProfilingV2Enabled]) {
164168
return sentry_launchShouldHaveContinuousProfilingV2(options);
165169
}
170+
# if SDK_V9
171+
return (SentryLaunchProfileConfig) { NO, nil, nil };
172+
# else
166173

167-
# pragma clang diagnostic push
168-
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
174+
# pragma clang diagnostic push
175+
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
169176
if ([options isContinuousProfilingEnabled]) {
170177
return (SentryLaunchProfileConfig) { options.enableAppLaunchProfiling, nil, nil };
171178
}
172-
# pragma clang diagnostic pop
179+
# pragma clang diagnostic pop
173180

174181
return sentry_launchShouldHaveTransactionProfiling(options);
182+
# endif // SDK_V9
175183
}
176184

177185
SentryTransactionContext *
@@ -236,12 +244,14 @@
236244
return;
237245
}
238246

247+
# if !SDK_V9
239248
if ([launchConfig[kSentryLaunchProfileConfigKeyContinuousProfiling] boolValue]) {
240249
SENTRY_LOG_DEBUG(@"Starting continuous launch profile v1.");
241250
[SentryContinuousProfiler start];
242251
_sentry_cleanUpConfigFile();
243252
return;
244253
}
254+
# endif // !SDK_V9
245255

246256
SentryProfileOptions *profileOptions = nil;
247257
if ([launchConfig[kSentryLaunchProfileConfigKeyContinuousProfilingV2] boolValue]) {
@@ -355,8 +365,10 @@
355365

356366
NSMutableDictionary<NSString *, NSNumber *> *configDict =
357367
[NSMutableDictionary<NSString *, NSNumber *> dictionary];
368+
# if !SDK_V9
358369
if ([options isContinuousProfilingEnabled]) {
359370
if ([options isContinuousProfilingV2Enabled]) {
371+
# endif // !SDK_V9
360372
SENTRY_LOG_DEBUG(@"Configuring continuous launch profile v2.");
361373
configDict[kSentryLaunchProfileConfigKeyContinuousProfilingV2] = @YES;
362374
configDict[kSentryLaunchProfileConfigKeyContinuousProfilingV2Lifecycle] =
@@ -371,6 +383,7 @@
371383
= config.profilesDecision.sampleRate;
372384
configDict[kSentryLaunchProfileConfigKeyProfilesSampleRand]
373385
= config.profilesDecision.sampleRand;
386+
# if !SDK_V9
374387
} else {
375388
SENTRY_LOG_DEBUG(@"Configuring continuous launch profile.");
376389
configDict[kSentryLaunchProfileConfigKeyContinuousProfiling] = @YES;
@@ -386,6 +399,7 @@
386399
configDict[kSentryLaunchProfileConfigKeyProfilesSampleRand]
387400
= config.profilesDecision.sampleRand;
388401
}
402+
# endif // !SDK_V9
389403
writeAppLaunchProfilingConfigFile(configDict);
390404
}];
391405
}

Sources/Sentry/Profiling/SentryProfiledTracerConcurrency.mm

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,12 @@
178178
internalTraceId.sentryIdString);
179179
_unsafe_cleanUpContinuousProfilerV2();
180180
} else if (internalTraceId != nil) {
181+
# if !SDK_V9
181182
if ([hub.getClient.options isContinuousProfilingEnabled]) {
183+
# endif // !SDK_V9
182184
SENTRY_TEST_FATAL(@"Tracers are not tracked with continuous profiling V1.");
183185
return;
186+
# if !SDK_V9
184187
}
185188

186189
if (_gTracersToProfilers == nil) {
@@ -197,15 +200,16 @@
197200

198201
_unsafe_cleanUpTraceProfiler(profiler, tracerKey);
199202

200-
# if SENTRY_HAS_UIKIT
203+
# if SENTRY_HAS_UIKIT
201204
if (_gProfilersToTracers == nil) {
202205
SENTRY_TEST_FATAL(@"Profiler to tracer structure should have already been "
203206
@"initialized by the time they are being queried");
204207
}
205208
if (_gProfilersToTracers.count == 0) {
206209
[SentryDependencyContainer.sharedInstance.framesTracker resetProfilingTimestamps];
207210
}
208-
# endif // SENTRY_HAS_UIKIT
211+
# endif // SENTRY_HAS_UIKIT
212+
# endif // !SDK_V9
209213
}
210214
}
211215

@@ -342,8 +346,13 @@
342346
} else {
343347
BOOL profileShouldBeSampled
344348
= configuration.profilesSamplerDecision.decision == kSentrySampleDecisionYes;
349+
# if !SDK_V9
345350
BOOL isContinuousProfiling = [hub.client.options isContinuousProfilingEnabled];
346351
BOOL shouldStartNormalTraceProfile = !isContinuousProfiling && profileShouldBeSampled;
352+
# else
353+
BOOL shouldStartNormalTraceProfile = profileShouldBeSampled;
354+
# endif // !SDK_V9
355+
347356
if (sentry_isTracingAppLaunch || shouldStartNormalTraceProfile) {
348357
SentryId *internalID = [[SentryId alloc] init];
349358
if ([SentryTraceProfiler startWithTracer:internalID]) {

Sources/Sentry/Public/SentryOptions.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,7 @@ typedef void (^SentryProfilingConfigurationBlock)(SentryProfileOptions *_Nonnull
530530
*/
531531
@property (nullable, nonatomic, copy) SentryProfilingConfigurationBlock configureProfiling;
532532

533+
# if !SDK_V9
533534
/**
534535
* @warning This is an experimental feature and may still have bugs.
535536
* Set to @c YES to run the profiler as early as possible in an app launch, before you would
@@ -620,6 +621,7 @@ typedef void (^SentryProfilingConfigurationBlock)(SentryProfileOptions *_Nonnull
620621
@property (nonatomic, assign) BOOL enableProfiling DEPRECATED_MSG_ATTRIBUTE(
621622
"Use profilesSampleRate or profilesSampler instead. This property will be removed in a future "
622623
"version of the SDK");
624+
# endif // !SDK_V9
623625
#endif // SENTRY_TARGET_PROFILING_SUPPORTED
624626

625627
/**

Sources/Sentry/SentryHub.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,13 +464,13 @@ - (SentryTracer *)startTransactionWithContext:(SentryTransactionContext *)transa
464464
sampleRate:tracesSamplerDecision.sampleRate
465465
sampleRand:tracesSamplerDecision.sampleRand];
466466

467-
#if SENTRY_TARGET_PROFILING_SUPPORTED
467+
#if SENTRY_TARGET_PROFILING_SUPPORTED && !SDK_V9
468468
if (![self.client.options isContinuousProfilingEnabled]) {
469469
SentrySamplerDecision *profilesSamplerDecision = sentry_sampleTraceProfile(
470470
samplingContext, tracesSamplerDecision, self.client.options);
471471
configuration.profilesSamplerDecision = profilesSamplerDecision;
472472
}
473-
#endif // SENTRY_TARGET_PROFILING_SUPPORTED"
473+
#endif // SENTRY_TARGET_PROFILING_SUPPORTED && !SDK_V9
474474

475475
SentryTracer *tracer = [[SentryTracer alloc] initWithTransactionContext:transactionContext
476476
hub:self

Sources/Sentry/SentryOptions.m

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,13 @@ - (instancetype)init
154154
self.enableNetworkBreadcrumbs = YES;
155155
self.tracesSampleRate = nil;
156156
#if SENTRY_TARGET_PROFILING_SUPPORTED
157+
# if !SDK_V9
157158
_enableProfiling = NO;
158-
# pragma clang diagnostic push
159-
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
159+
# pragma clang diagnostic push
160+
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
160161
self.profilesSampleRate = SENTRY_INITIAL_PROFILES_SAMPLE_RATE;
161-
# pragma clang diagnostic pop
162+
# pragma clang diagnostic pop
163+
# endif // !SDK_V9
162164
#endif // SENTRY_TARGET_PROFILING_SUPPORTED
163165
self.enableCoreDataTracing = YES;
164166
_enableSwizzling = YES;
@@ -544,25 +546,27 @@ - (BOOL)validateOptions:(NSDictionary<NSString *, id> *)options
544546
block:^(BOOL value) { self->_enableCoreDataTracing = value; }];
545547

546548
#if SENTRY_TARGET_PROFILING_SUPPORTED
549+
# if !SDK_V9
547550
if ([options[@"profilesSampleRate"] isKindOfClass:[NSNumber class]]) {
548-
# pragma clang diagnostic push
549-
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
551+
# pragma clang diagnostic push
552+
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
550553
self.profilesSampleRate = options[@"profilesSampleRate"];
551-
# pragma clang diagnostic pop
554+
# pragma clang diagnostic pop
552555
}
553556

554-
# pragma clang diagnostic push
555-
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
557+
# pragma clang diagnostic push
558+
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
556559
if ([self isBlock:options[@"profilesSampler"]]) {
557560
self.profilesSampler = options[@"profilesSampler"];
558561
}
559-
# pragma clang diagnostic pop
562+
# pragma clang diagnostic pop
560563

561564
[self setBool:options[@"enableProfiling"]
562565
block:^(BOOL value) { self->_enableProfiling = value; }];
563566

564567
[self setBool:options[NSStringFromSelector(@selector(enableAppLaunchProfiling))]
565568
block:^(BOOL value) { self->_enableAppLaunchProfiling = value; }];
569+
# endif // !SDK_V9
566570
#endif // SENTRY_TARGET_PROFILING_SUPPORTED
567571

568572
[self setBool:options[@"sendClientReports"]
@@ -685,6 +689,7 @@ - (BOOL)isTracingEnabled
685689
}
686690

687691
#if SENTRY_TARGET_PROFILING_SUPPORTED
692+
# if !SDK_V9
688693
- (void)setProfilesSampleRate:(NSNumber *)profilesSampleRate
689694
{
690695
if (profilesSampleRate == nil) {
@@ -704,41 +709,53 @@ - (BOOL)isProfilingEnabled
704709

705710
- (BOOL)isContinuousProfilingEnabled
706711
{
707-
# pragma clang diagnostic push
708-
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
712+
# pragma clang diagnostic push
713+
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
709714
// this looks a little weird with the `!self.enableProfiling` but that actually is the
710715
// deprecated way to say "enable trace-based profiling", which necessarily disables continuous
711716
// profiling as they are mutually exclusive modes
712717
return _profilesSampleRate == nil && _profilesSampler == nil && !self.enableProfiling;
713-
# pragma clang diagnostic pop
718+
# pragma clang diagnostic pop
714719
}
715720

721+
# endif // !SDK_V9
722+
716723
- (BOOL)isContinuousProfilingV2Enabled
717724
{
725+
# if SDK_V9
726+
return _profiling != nil;
727+
# else
718728
return [self isContinuousProfilingEnabled] && _profiling != nil;
729+
# endif // SDK_V9
719730
}
720731

721732
- (BOOL)isProfilingCorrelatedToTraces
722733
{
734+
# if SDK_V9
735+
return _profiling != nil && _profiling.lifecycle == SentryProfileLifecycleTrace;
736+
# else
723737
return ![self isContinuousProfilingEnabled]
724738
|| (_profiling != nil && _profiling.lifecycle == SentryProfileLifecycleTrace);
739+
# endif // SDK_V9
725740
}
726741

742+
# if !SDK_V9
727743
- (void)setEnableProfiling_DEPRECATED_TEST_ONLY:(BOOL)enableProfiling_DEPRECATED_TEST_ONLY
728744
{
729-
# pragma clang diagnostic push
730-
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
745+
# pragma clang diagnostic push
746+
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
731747
self.enableProfiling = enableProfiling_DEPRECATED_TEST_ONLY;
732-
# pragma clang diagnostic pop
748+
# pragma clang diagnostic pop
733749
}
734750

735751
- (BOOL)enableProfiling_DEPRECATED_TEST_ONLY
736752
{
737-
# pragma clang diagnostic push
738-
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
753+
# pragma clang diagnostic push
754+
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
739755
return self.enableProfiling;
740-
# pragma clang diagnostic pop
756+
# pragma clang diagnostic pop
741757
}
758+
# endif // !SDK_V9
742759
#endif // SENTRY_TARGET_PROFILING_SUPPORTED
743760

744761
/**

Sources/Sentry/SentryProfiler.mm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
void
4949
sentry_configureContinuousProfiling(SentryOptions *options)
5050
{
51+
# if !SDK_V9
5152
if (![options isContinuousProfilingEnabled]) {
5253
if (options.configureProfiling != nil) {
5354
SENTRY_LOG_WARN(@"In order to configure SentryProfileOptions you must remove "
@@ -56,6 +57,7 @@
5657
}
5758
return;
5859
}
60+
# endif // !SDK_V9
5961

6062
if (options.configureProfiling == nil) {
6163
SENTRY_LOG_DEBUG(@"Continuous profiling V2 configuration not set by SDK consumer, nothing "
@@ -90,8 +92,10 @@
9092
// get the configuration options from the last time the launch config was written; it may be
9193
// different than the new options the SDK was just started with
9294
const auto configDict = sentry_appLaunchProfileConfiguration();
95+
# if !SDK_V9
9396
const auto profileIsContinuousV1 =
9497
[configDict[kSentryLaunchProfileConfigKeyContinuousProfiling] boolValue];
98+
# endif // !SDK_V9
9599
const auto profileIsContinuousV2 =
96100
[configDict[kSentryLaunchProfileConfigKeyContinuousProfilingV2] boolValue];
97101
const auto v2LifecycleValue
@@ -116,7 +120,11 @@
116120
}
117121
# endif // SENTRY_HAS_UIKIT
118122

123+
# if !SDK_V9
119124
if (profileIsContinuousV1 || v2LifecycleIsManual) {
125+
# else
126+
if (v2LifecycleIsManual) {
127+
# endif // !SDK_V9
120128
SENTRY_LOG_DEBUG(
121129
@"Continuous manual launch profiles aren't stopped on calls to SentrySDK.start, "
122130
@"not stopping profile.");

Sources/Sentry/SentrySDK.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,7 @@ + (void)crash
680680
+ (void)startProfiler
681681
{
682682
SentryOptions *options = currentHub.client.options;
683+
# if !SDK_V9
683684
if (![options isContinuousProfilingEnabled]) {
684685
SENTRY_LOG_WARN(
685686
@"You must disable trace profiling by setting SentryOptions.profilesSampleRate and "
@@ -689,6 +690,7 @@ + (void)startProfiler
689690
@"relies on deprecated options and will change in a future version.");
690691
return;
691692
}
693+
# endif // !SDK_V9
692694

693695
if (options.profiling != nil) {
694696
if (options.profiling.lifecycle == SentryProfileLifecycleTrace) {
@@ -716,6 +718,7 @@ + (void)startProfiler
716718
+ (void)stopProfiler
717719
{
718720
SentryOptions *options = currentHub.client.options;
721+
# if !SDK_V9
719722
if (![options isContinuousProfilingEnabled]) {
720723
SENTRY_LOG_WARN(
721724
@"You must disable trace profiling by setting SentryOptions.profilesSampleRate and "
@@ -725,6 +728,7 @@ + (void)stopProfiler
725728
@"relies on deprecated options and will change in a future version.");
726729
return;
727730
}
731+
# endif // !SDK_V9
728732

729733
if (options.profiling != nil && options.profiling.lifecycle == SentryProfileLifecycleTrace) {
730734
SENTRY_LOG_WARN(

0 commit comments

Comments
 (0)