Skip to content

feat(v9): Remove profiling APIs deprecated in V9 #5616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,10 @@ public enum SentrySDKOverrides: String, CaseIterable {
case tracing = "Tracing"

public enum Profiling: String, SentrySDKOverride {
#if !SDK_V9
case sampleRate = "--io.sentry.profiling.profilesSampleRate"
case samplerValue = "--io.sentry.profiling.profilesSamplerValue"
#endif // !SDK_V9
case disableAppStartProfiling = "--io.sentry.profiling.disable-app-start-profiling"
case manualLifecycle = "--io.sentry.profiling.profile-lifecycle-manual"
case sessionSampleRate = "--io.sentry.profiling.profile-session-sample-rate"
Expand Down Expand Up @@ -238,7 +240,11 @@ private extension SentrySDKOverride {
extension SentrySDKOverrides.Profiling {
public var overrideType: OverrideType {
switch self {
#if SDK_V9
case .sessionSampleRate: return .float
#else
case .sampleRate, .samplerValue, .sessionSampleRate: return .float
#endif // !SDK_V9
case .disableAppStartProfiling, .manualLifecycle, .disableUIProfiling, .slowLoadMethod, .immediateStop: return .boolean
}
}
Expand Down Expand Up @@ -305,7 +311,11 @@ extension SentrySDKOverrides.Special {
extension SentrySDKOverrides.Profiling {
public var ignoresDisableEverything: Bool {
switch self {
#if SDK_V9
case .sessionSampleRate, .manualLifecycle, .slowLoadMethod, .immediateStop: return true
#else
case .sampleRate, .samplerValue, .sessionSampleRate, .manualLifecycle, .slowLoadMethod, .immediateStop: return true
#endif // SDK_V9
case .disableAppStartProfiling, .disableUIProfiling: return false
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ extension SentrySDKWrapper {
#if !os(tvOS) && !os(watchOS) && !os(visionOS)
extension SentrySDKWrapper {
func configureProfiling(_ options: Options) {
#if !SDK_V9
if let sampleRate = SentrySDKOverrides.Profiling.sampleRate.floatValue {
options.profilesSampleRate = NSNumber(value: sampleRate)
}
Expand All @@ -434,6 +435,7 @@ extension SentrySDKWrapper {
}
}
options.enableAppLaunchProfiling = !SentrySDKOverrides.Profiling.disableAppStartProfiling.boolValue
#endif // !SDK_V9

if !SentrySDKOverrides.Profiling.disableUIProfiling.boolValue {
options.configureProfiling = {
Expand Down
20 changes: 11 additions & 9 deletions Samples/iOS-ObjectiveC/iOS-ObjectiveC/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,31 +51,33 @@ - (BOOL)application:(UIApplication *)application
};
}

#if !SDK_V9
if (env[@"--io.sentry.profiling.profilesSampleRate"] != nil) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
options.profilesSampleRate =
@([env[@"--io.sentry.profiling.profilesSampleRate"] floatValue]);
#pragma clang diagnostic pop
# pragma clang diagnostic pop
}

if (env[@"--io.sentry.profilesSamplerValue"] != nil) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
options.profilesSampler
= ^NSNumber *_Nullable(SentrySamplingContext *_Nonnull samplingContext)
{
return @([env[@"--io.sentry.profilesSamplerValue"] floatValue]);
};
#pragma clang diagnostic pop
# pragma clang diagnostic pop
}

if (![args containsObject:@"--io.sentry.profiling.disable-app-start-profiling"]) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
options.enableAppLaunchProfiling = YES;
#pragma clang diagnostic pop
# pragma clang diagnostic pop
}
#endif // !SDK_V9

SentryHttpStatusCodeRange *httpStatusCodeRange =
[[SentryHttpStatusCodeRange alloc] initWithMin:400 max:599];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ class ProfilingViewController: UIViewController, UITextFieldDelegate {
}

@IBAction func sampleRateEdited(_ sender: UITextField) {
#if !SDK_V9
var sampleRate = SentrySDKOverrides.Profiling.sampleRate
sampleRate.floatValue = getSampleRateOverride(field: sender)
#endif // !SDK_V9
}

@IBAction func tracesSampleRateEdited(_ sender: UITextField) {
Expand All @@ -76,8 +78,10 @@ class ProfilingViewController: UIViewController, UITextFieldDelegate {
@IBAction func defineProfilesSampleRateToggled(_ sender: UISwitch) {
sampleRateField.isEnabled = sender.isOn

#if !SDK_V9
var sampleRate = SentrySDKOverrides.Profiling.sampleRate
sampleRate.floatValue = getSampleRateOverride(field: sampleRateField)
#endif // !SDK_V9
}

@IBAction func defineTracesSampleRateToggled(_ sender: UISwitch) {
Expand Down
36 changes: 27 additions & 9 deletions Sources/Sentry/Profiling/SentryLaunchProfiling.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
NSString *const kSentryLaunchProfileConfigKeyTracesSampleRand = @"traces.sample_rand";
NSString *const kSentryLaunchProfileConfigKeyProfilesSampleRate = @"profiles";
NSString *const kSentryLaunchProfileConfigKeyProfilesSampleRand = @"profiles.sample_rand";
# if !SDK_V9
NSString *const kSentryLaunchProfileConfigKeyContinuousProfiling = @"continuous-profiling";
# endif // !SDK_V9
NSString *const kSentryLaunchProfileConfigKeyContinuousProfilingV2
= @"continuous-profiling-v2-enabled";
NSString *const kSentryLaunchProfileConfigKeyContinuousProfilingV2Lifecycle
Expand Down Expand Up @@ -161,11 +163,12 @@
configuration:tracerConfig];
}

# if !SDK_V9
SentryLaunchProfileDecision
sentry_launchShouldHaveTransactionProfiling(SentryOptions *options)
{
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
BOOL shouldProfileNextLaunch = options.enableAppLaunchProfiling && options.enableTracing;
if (!shouldProfileNextLaunch) {
SENTRY_LOG_DEBUG(@"Specified options configuration doesn't enable launch profiling: "
Expand All @@ -174,7 +177,7 @@
options.enableAppLaunchProfiling, options.enableTracing);
return (SentryLaunchProfileDecision) { NO, nil, nil };
}
# pragma clang diagnostic pop
# pragma clang diagnostic pop

SentryTransactionContext *transactionContext =
[[SentryTransactionContext alloc] initWithName:@"app.launch" operation:@"profile"];
Expand All @@ -199,6 +202,7 @@
SENTRY_LOG_DEBUG(@"Will start transaction profile next launch; will profile launch.");
return (SentryLaunchProfileDecision) { YES, tracesSamplerDecision, profilesSamplerDecision };
}
# endif // !SDK_V9

SentryLaunchProfileDecision
sentry_launchShouldHaveContinuousProfilingV2(SentryOptions *options)
Expand Down Expand Up @@ -261,15 +265,19 @@
if ([options isContinuousProfilingV2Enabled]) {
return sentry_launchShouldHaveContinuousProfilingV2(options);
}
# if SDK_V9
return (SentryLaunchProfileDecision) { NO, nil, nil };
# else

# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
if ([options isContinuousProfilingEnabled]) {
return (SentryLaunchProfileDecision) { options.enableAppLaunchProfiling, nil, nil };
}
# pragma clang diagnostic pop
# pragma clang diagnostic pop

return sentry_launchShouldHaveTransactionProfiling(options);
# endif // SDK_V9
}

/**
Expand Down Expand Up @@ -313,17 +321,21 @@
NSDictionary<NSString *, NSNumber *> *persistedLaunchConfigOptionsDict
= sentry_persistedLaunchProfileConfigurationOptions();

BOOL isContinuousV1 =
[persistedLaunchConfigOptionsDict[kSentryLaunchProfileConfigKeyContinuousProfiling]
boolValue];
BOOL isContinuousV2 =
[persistedLaunchConfigOptionsDict[kSentryLaunchProfileConfigKeyContinuousProfilingV2]
boolValue];
# if !SDK_V9
BOOL isContinuousV1 =
[persistedLaunchConfigOptionsDict[kSentryLaunchProfileConfigKeyContinuousProfiling]
boolValue];
if (isContinuousV1 && isContinuousV2) {
SENTRY_LOG_WARN(@"Launch profile misconfiguration detected.");
_sentry_cleanUpConfigFile();
return;
}
# else
BOOL isContinuousV1 = false;
# endif // !SDK_V9

SentrySamplerDecision *decision
= _sentry_profileSampleDecision(persistedLaunchConfigOptionsDict);
Expand Down Expand Up @@ -408,7 +420,9 @@
[NSMutableDictionary<NSString *, NSNumber *> dictionary];
configDict[kSentryLaunchProfileConfigKeyWaitForFullDisplay] =
@(options.enableTimeToFullDisplayTracing);
# if !SDK_V9
if ([options isContinuousProfilingEnabled]) {
# endif // !SDK_V9
if ([options isContinuousProfilingV2Enabled]) {
SENTRY_LOG_DEBUG(@"Configuring continuous launch profile v2.");
configDict[kSentryLaunchProfileConfigKeyContinuousProfilingV2] = @YES;
Expand All @@ -425,9 +439,12 @@
configDict[kSentryLaunchProfileConfigKeyProfilesSampleRand]
= config.profilesDecision.sampleRand;
} else {
# if !SDK_V9
SENTRY_LOG_DEBUG(@"Configuring continuous launch profile.");
configDict[kSentryLaunchProfileConfigKeyContinuousProfiling] = @YES;
# endif // !SDK_V9
}
# if !SDK_V9
} else {
SENTRY_LOG_DEBUG(@"Configuring trace launch profile.");
configDict[kSentryLaunchProfileConfigKeyTracesSampleRate]
Expand All @@ -439,6 +456,7 @@
configDict[kSentryLaunchProfileConfigKeyProfilesSampleRand]
= config.profilesDecision.sampleRand;
}
# endif // !SDK_V9
writeAppLaunchProfilingConfigFile(configDict);
}];
}
Expand Down
7 changes: 7 additions & 0 deletions Sources/Sentry/Profiling/SentryProfiledTracerConcurrency.mm
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,12 @@
sentry_stringFromSentryID(internalTraceId));
_unsafe_cleanUpContinuousProfilerV2();
} else if (internalTraceId != nil) {
# if !SDK_V9
if (sentry_isContinuousProfilingEnabled(hub.getClient)) {
SENTRY_LOG_ERROR(@"Tracers are not tracked with continuous profiling V1.");
return;
}
# endif // !SDK_V9

if (_gTracersToProfilers == nil) {
SENTRY_LOG_ERROR(@"Tracer to profiler should have already been initialized by the "
Expand Down Expand Up @@ -351,8 +353,13 @@
} else {
BOOL profileShouldBeSampled
= configuration.profilesSamplerDecision.decision == kSentrySampleDecisionYes;
# if !SDK_V9
BOOL isContinuousProfiling = sentry_isContinuousProfilingEnabled(hub.client);
BOOL shouldStartNormalTraceProfile = !isContinuousProfiling && profileShouldBeSampled;
# else
BOOL shouldStartNormalTraceProfile = profileShouldBeSampled;
# endif // !SDK_V9

if (sentry_isTracingAppLaunch || shouldStartNormalTraceProfile) {
SentryId *internalID = sentry_getSentryId();
if ([SentryTraceProfiler startWithTracer:internalID]) {
Expand Down
2 changes: 2 additions & 0 deletions Sources/Sentry/Profiling/SentryProfilingSwiftHelpers.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
# import "SentrySamplerDecision.h"
# import "SentrySwift.h"

# if !SDK_V9
BOOL
sentry_isContinuousProfilingEnabled(SentryClient *client)
{
return [client.options isContinuousProfilingEnabled];
}
# endif // !SDK_V9

BOOL
sentry_isContinuousProfilingV2Enabled(SentryClient *client)
Expand Down
3 changes: 2 additions & 1 deletion Sources/Sentry/Public/SentryOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@ typedef void (^SentryProfilingConfigurationBlock)(SentryProfileOptions *_Nonnull
*/
@property (nullable, nonatomic, copy) SentryProfilingConfigurationBlock configureProfiling;

# if !SDK_V9
/**
* @warning This is an experimental feature and may still have bugs.
* Set to @c YES to run the profiler as early as possible in an app launch, before you would
Expand Down Expand Up @@ -592,7 +593,6 @@ typedef void (^SentryProfilingConfigurationBlock)(SentryProfileOptions *_Nonnull
SentryTracesSamplerCallback profilesSampler NS_SWIFT_SENDABLE DEPRECATED_MSG_ATTRIBUTE(
"This property is deprecated and will be removed in a future version of the SDK. See "
"SentryProfileOptions.sessionSampleRate");
;

/**
* If profiling should be enabled or not.
Expand Down Expand Up @@ -620,6 +620,7 @@ typedef void (^SentryProfilingConfigurationBlock)(SentryProfileOptions *_Nonnull
@property (nonatomic, assign) BOOL enableProfiling DEPRECATED_MSG_ATTRIBUTE(
"Use profilesSampleRate or profilesSampler instead. This property will be removed in a future "
"version of the SDK");
# endif // !SDK_V9
#endif // SENTRY_TARGET_PROFILING_SUPPORTED

/**
Expand Down
4 changes: 2 additions & 2 deletions Sources/Sentry/SentryHub.m
Original file line number Diff line number Diff line change
Expand Up @@ -464,13 +464,13 @@ - (SentryTracer *)startTransactionWithContext:(SentryTransactionContext *)transa
sampleRate:tracesSamplerDecision.sampleRate
sampleRand:tracesSamplerDecision.sampleRand];

#if SENTRY_TARGET_PROFILING_SUPPORTED
#if SENTRY_TARGET_PROFILING_SUPPORTED && !SDK_V9
if (![self.client.options isContinuousProfilingEnabled]) {
SentrySamplerDecision *profilesSamplerDecision = sentry_sampleTraceProfile(
samplingContext, tracesSamplerDecision, self.client.options);
configuration.profilesSamplerDecision = profilesSamplerDecision;
}
#endif // SENTRY_TARGET_PROFILING_SUPPORTED"
#endif // SENTRY_TARGET_PROFILING_SUPPORTED && !SDK_V9

SentryTracer *tracer = [[SentryTracer alloc] initWithTransactionContext:transactionContext
hub:self
Expand Down
Loading
Loading