Skip to content

Commit

Permalink
chore: Deprecate options.enableTracing. (#4182)
Browse files Browse the repository at this point in the history
Deprecating options.enableTracing in order to completely remove it in the next major
  • Loading branch information
brustolin authored Jul 24, 2024
1 parent bce565d commit bb71736
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions Sources/Sentry/Profiling/SentryLaunchProfiling.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,16 @@
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: "
@"options.enableAppLaunchProfiling: %d; options.enableTracing: %d",
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;
Expand Down
7 changes: 4 additions & 3 deletions Sources/Sentry/Public/SentryOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;

Expand Down
4 changes: 3 additions & 1 deletion Sources/Sentry/SentryOptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,12 @@ - (BOOL)validateOptions:(NSDictionary<NSString *, id> *)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<NSString *> *inAppIncludes =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions Tests/SentryTests/SentryOptionsTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 }];
Expand Down Expand Up @@ -976,6 +981,7 @@ - (void)testTracesSampleRate
XCTAssertEqual(options.tracesSampleRate.doubleValue, 0.1);
XCTAssertTrue(options.enableTracing);
}
#pragma clang diagnostic pop

- (void)testDefaultTracesSampleRate
{
Expand Down Expand Up @@ -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) {
Expand All @@ -1041,6 +1049,7 @@ - (void)testTracesSampler
XCTAssertEqual(options.tracesSampler(context), @1.0);
XCTAssertTrue(options.enableTracing);
}
#pragma clang diagnostic pop

- (void)testDefaultTracesSampler
{
Expand Down

0 comments on commit bb71736

Please sign in to comment.