Skip to content

Commit

Permalink
only do this for continuous profiler
Browse files Browse the repository at this point in the history
  • Loading branch information
armcknight committed May 23, 2024
1 parent 5f7447b commit 7b3ad5f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
28 changes: 16 additions & 12 deletions Sources/Sentry/SentrySpan.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
#import "SentryNSDictionarySanitize.h"
#import "SentryNSNotificationCenterWrapper.h"
#import "SentryNoOpSpan.h"
#import "SentryOptions+Private.h"
#import "SentryProfilingConditionals.h"
#import "SentrySDK+Private.h"
#import "SentrySampleDecision+Private.h"
#import "SentrySpanContext.h"
#import "SentrySpanId.h"
Expand Down Expand Up @@ -96,19 +98,21 @@ - (instancetype)initWithContext:(SentrySpanContext *)context
_origin = context.origin;

#if SENTRY_TARGET_PROFILING_SUPPORTED
_profileSessionIDs = [NSMutableSet<NSString *> set];
if (SentryContinuousProfiler.isCurrentlyProfiling) {
[_profileSessionIDs
addObject:SentryContinuousProfiler.currentProfilerID.sentryIdString];
if (SentrySDK.options.enableContinuousProfiling) {
_profileSessionIDs = [NSMutableSet<NSString *> set];
if (SentryContinuousProfiler.isCurrentlyProfiling) {
[_profileSessionIDs
addObject:SentryContinuousProfiler.currentProfilerID.sentryIdString];
}
[SentryDependencyContainer.sharedInstance.notificationCenterWrapper
addObserver:self
selector:@selector(linkProfiler)
name:kSentryNotificationContinuousProfileStarted];
[SentryDependencyContainer.sharedInstance.notificationCenterWrapper
addObserver:self
selector:@selector(linkProfiler)
name:kSentryNotificationContinuousProfileStopped];
}
[SentryDependencyContainer.sharedInstance.notificationCenterWrapper
addObserver:self
selector:@selector(linkProfiler)
name:kSentryNotificationContinuousProfileStarted];
[SentryDependencyContainer.sharedInstance.notificationCenterWrapper
addObserver:self
selector:@selector(linkProfiler)
name:kSentryNotificationContinuousProfileStopped];
#endif // SENTRY_TARGET_PROFILING_SUPPORTED
}
return self;
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/SentrySpanContext.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#import "SentrySpanContext.h"
#import "SentryLog.h"
#import "SentrySampleDecision+Private.h"
#import "SentrySpanContext+Private.h"
#import "SentrySpanId.h"
#import "SentrySwift.h"
#import "SentryTraceOrigins.h"
Expand Down
12 changes: 11 additions & 1 deletion Tests/SentryTests/Transaction/SentrySpanTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,17 @@ class SentrySpanTests: XCTestCase {
super.tearDown()
clearTestState()
}


func testSpanDoesNotIncludeTraceProfilerID() throws {
fixture.options.profilesSampleRate = 1
let span = fixture.getSut()
XCTAssert(SentryTraceProfiler.isCurrentlyProfiling())
span.finish()

let serialized = span.serialize()
XCTAssertNil(serialized["profile_ids"])
}

// test that a span that starts before a continuous profile and ends before
// the profile ends includes that profile id in the span
func testSpanWithProfileId() throws {
Expand Down

0 comments on commit 7b3ad5f

Please sign in to comment.