From bb717364718a37adaf01eff7ab282b76aeaacb43 Mon Sep 17 00:00:00 2001 From: Dhiogo Brustolin Date: Wed, 24 Jul 2024 08:57:27 +0200 Subject: [PATCH] chore: Deprecate options.enableTracing. (#4182) Deprecating options.enableTracing in order to completely remove it in the next major --- CHANGELOG.md | 4 ++++ Sources/Sentry/Profiling/SentryLaunchProfiling.m | 5 +++-- Sources/Sentry/Public/SentryOptions.h | 7 ++++--- Sources/Sentry/SentryOptions.m | 4 +++- .../SentryAppLaunchProfilingTests.swift | 2 +- Tests/SentryTests/SentryOptionsTest.m | 9 +++++++++ 6 files changed, 24 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc00388b896..119d41afd8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ - Session replay crash when writing the replay (#4186) +### Deprecated + +- options.enableTracing was deprecated. Use options.tracesSampleRate or options.tracesSampler instead. (#4182) + ## 8.31.1 ### Fixes diff --git a/Sources/Sentry/Profiling/SentryLaunchProfiling.m b/Sources/Sentry/Profiling/SentryLaunchProfiling.m index 2a8754c37ff..e3af3a4eff9 100644 --- a/Sources/Sentry/Profiling/SentryLaunchProfiling.m +++ b/Sources/Sentry/Profiling/SentryLaunchProfiling.m @@ -59,7 +59,8 @@ if (options.enableAppLaunchProfiling && [options isContinuousProfilingEnabled]) { return (SentryLaunchProfileConfig) { YES, nil, nil }; } - +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wdeprecated-declarations" BOOL shouldProfileNextLaunch = options.enableAppLaunchProfiling && options.enableTracing; if (!shouldProfileNextLaunch) { SENTRY_LOG_DEBUG(@"Won't profile next launch due to specified options configuration: " @@ -67,7 +68,7 @@ options.enableAppLaunchProfiling, options.enableTracing); return (SentryLaunchProfileConfig) { NO, nil, nil }; } - +# pragma clang diagnostic pop SentryTransactionContext *transactionContext = [[SentryTransactionContext alloc] initWithName:@"app.launch" operation:@"profile"]; transactionContext.forNextAppLaunch = YES; diff --git a/Sources/Sentry/Public/SentryOptions.h b/Sources/Sentry/Public/SentryOptions.h index 525448d9e9f..d98da46d920 100644 --- a/Sources/Sentry/Public/SentryOptions.h +++ b/Sources/Sentry/Public/SentryOptions.h @@ -334,7 +334,8 @@ NS_SWIFT_NAME(Options) * @c tracesSampler are @c nil. Changing either @c tracesSampleRate or @c tracesSampler to a value * other then @c nil will enable this in case this was never changed before. */ -@property (nonatomic) BOOL enableTracing; +@property (nonatomic) + BOOL enableTracing DEPRECATED_MSG_ATTRIBUTE("Use tracesSampleRate or tracesSampler instead"); /** * Indicates the percentage of the tracing data that is collected. @@ -360,8 +361,8 @@ NS_SWIFT_NAME(Options) /** * If tracing is enabled or not. - * @discussion @c YES if @c enabledTracing is @c YES and @c tracesSampleRate - * is > @c 0 and \<= @c 1 or a @c tracesSampler is set, otherwise @c NO. + * @discussion @c YES if @c tracesSampleRateis > @c 0 and \<= @c 1 + * or a @c tracesSampler is set, otherwise @c NO. */ @property (nonatomic, assign, readonly) BOOL isTracingEnabled; diff --git a/Sources/Sentry/SentryOptions.m b/Sources/Sentry/SentryOptions.m index b27fef1cbee..de2f29e288e 100644 --- a/Sources/Sentry/SentryOptions.m +++ b/Sources/Sentry/SentryOptions.m @@ -448,10 +448,12 @@ - (BOOL)validateOptions:(NSDictionary *)options if ([self isBlock:options[@"tracesSampler"]]) { self.tracesSampler = options[@"tracesSampler"]; } - +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" if ([options[@"enableTracing"] isKindOfClass:NSNumber.self]) { self.enableTracing = [options[@"enableTracing"] boolValue]; } +#pragma clang diagnostic pop if ([options[@"inAppIncludes"] isKindOfClass:[NSArray class]]) { NSArray *inAppIncludes = diff --git a/Tests/SentryProfilerTests/SentryAppLaunchProfilingTests.swift b/Tests/SentryProfilerTests/SentryAppLaunchProfilingTests.swift index 2cc70766ed3..8e165de7cd9 100644 --- a/Tests/SentryProfilerTests/SentryAppLaunchProfilingTests.swift +++ b/Tests/SentryProfilerTests/SentryAppLaunchProfilingTests.swift @@ -293,7 +293,7 @@ final class SentryAppLaunchProfilingSwiftTests: XCTestCase { ] { let options = Options() options.enableAppLaunchProfiling = testCase.enableAppLaunchProfiling - options.enableTracing = testCase.enableTracing + Dynamic(options).enableTracing = testCase.enableTracing options.tracesSampleRate = NSNumber(value: testCase.tracesSampleRate) if let profilesSampleRate = testCase.profilesSampleRate { options.profilesSampleRate = NSNumber(value: profilesSampleRate) diff --git a/Tests/SentryTests/SentryOptionsTest.m b/Tests/SentryTests/SentryOptionsTest.m index 004d9680035..f86dab500c3 100644 --- a/Tests/SentryTests/SentryOptionsTest.m +++ b/Tests/SentryTests/SentryOptionsTest.m @@ -659,7 +659,10 @@ - (void)assertDefaultValues:(SentryOptions *)options XCTAssertEqual(options.experimental.sessionReplay.errorSampleRate, 0); XCTAssertEqual(options.experimental.sessionReplay.sessionSampleRate, 0); #endif // SENTRY_HAS_UIKIT +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" XCTAssertFalse(options.enableTracing); +#pragma clang diagnostic pop XCTAssertTrue(options.enableAppHangTracking); XCTAssertEqual(options.appHangTimeoutInterval, 2); XCTAssertEqual(YES, options.enableNetworkTracking); @@ -909,6 +912,8 @@ - (void)testSwizzleClassNameExcludes XCTAssertEqualObjects(expected, options.swizzleClassNameExcludes); } +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" - (void)testEnableTracing { SentryOptions *options = [self getValidOptions:@{ @"enableTracing" : @YES }]; @@ -976,6 +981,7 @@ - (void)testTracesSampleRate XCTAssertEqual(options.tracesSampleRate.doubleValue, 0.1); XCTAssertTrue(options.enableTracing); } +#pragma clang diagnostic pop - (void)testDefaultTracesSampleRate { @@ -1028,6 +1034,8 @@ - (double)tracesSamplerCallback:(NSDictionary *)context return 0.1; } +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" - (void)testTracesSampler { SentryTracesSamplerCallback sampler = ^(SentrySamplingContext *context) { @@ -1041,6 +1049,7 @@ - (void)testTracesSampler XCTAssertEqual(options.tracesSampler(context), @1.0); XCTAssertTrue(options.enableTracing); } +#pragma clang diagnostic pop - (void)testDefaultTracesSampler {