Skip to content

ref(profiling): function renames #5007

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
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ac31821
ref: stick with startProfiler/stopProfiler methods to avoid confusion…
armcknight Mar 18, 2025
9269716
update language
armcknight Mar 18, 2025
925ae48
fix logic in start/stop methods
armcknight Mar 18, 2025
4e05207
fix test build
armcknight Mar 18, 2025
c1932c0
replace more instances of old names in headerdocs
armcknight Mar 18, 2025
6605471
move explanationn to changelog
armcknight Mar 19, 2025
68d4d41
Format code
getsentry-bot Mar 19, 2025
647a3c5
fix remaining combinations of tests
armcknight Mar 19, 2025
ffa3c89
change(profiling): deprecate old trace-and continuous profiling API
armcknight Feb 14, 2025
dc0686f
NOMAIN: temporarily disable warnings as errors until we figure out ho…
armcknight Feb 14, 2025
d186505
Format code
getsentry-bot Mar 21, 2025
d1dfcd0
fix bad merge conflict resolution
armcknight Mar 21, 2025
b6da0a4
ref(profiling): rename some functions/params
armcknight Mar 21, 2025
2100b7a
Format code
getsentry-bot Mar 21, 2025
0c4e27e
Merge branch 'armcknight/git-chain/profiling/new-continuous-apis/6-la…
armcknight Mar 21, 2025
b52e723
Merge branch 'armcknight/profiling/new-continuous-apis/7-combine-publ…
armcknight Mar 21, 2025
382aa90
Merge branch 'armcknight/git-chain/profiling/new-continuous-apis/6-la…
armcknight Mar 31, 2025
80e7242
Merge branch 'armcknight/profiling/new-continuous-apis/7-combine-publ…
armcknight Mar 31, 2025
c6a33dd
Merge branch 'armcknight/git-chain/profiling/new-continuous-apis/6-la…
armcknight Mar 31, 2025
e5f84e2
Merge branch 'armcknight/profiling/new-continuous-apis/7-combine-publ…
armcknight Mar 31, 2025
6f41b71
fixup! Merge branch 'armcknight/profiling/new-continuous-apis/7-combi…
armcknight Mar 31, 2025
5396862
Merge branch 'armcknight/git-chain/profiling/new-continuous-apis/6-la…
armcknight Mar 31, 2025
6107601
Merge branch 'armcknight/profiling/new-continuous-apis/7-combine-publ…
armcknight Mar 31, 2025
1b35560
fix bad merge conflict resolution
armcknight Mar 31, 2025
10e12a4
Merge branch 'armcknight/profiling/new-continuous-apis/7-combine-publ…
armcknight Mar 31, 2025
8b5cabe
Merge branch 'armcknight/git-chain/profiling/new-continuous-apis/6-la…
armcknight Apr 1, 2025
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
3 changes: 2 additions & 1 deletion SentryTestUtils/SentryLaunchProfiling+Tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ BOOL sentry_willProfileNextLaunch(SentryOptions *options);
*/
void _sentry_nondeduplicated_startLaunchProfile(void);

SentryTransactionContext *sentry_context(NSNumber *tracesRate, NSNumber *tracesRand);
SentryTransactionContext *sentry_contextForLaunchProfilerForTrace(
NSNumber *tracesRate, NSNumber *tracesRand);

NS_ASSUME_NONNULL_END

Expand Down
6 changes: 2 additions & 4 deletions Sources/Sentry/PrivateSentrySDKOnly.mm
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,9 @@ + (uint64_t)startProfilerForTrace:(SentryId *)traceId;
return payload;
}

+ (void)discardProfilerForTrace:(SentryId *)traceId
traceSampled:(BOOL)launchTraceSampledForContinuousProfilingV2;
+ (void)discardProfilerForTrace:(SentryId *)traceId traceSampled:(BOOL)isProfiling;
{
sentry_discardProfiler(
traceId, SentrySDK.currentHub, launchTraceSampledForContinuousProfilingV2);
sentry_discardProfilerCorrelatedToTrace(traceId, SentrySDK.currentHub, isProfiling);
}

#endif // SENTRY_TARGET_PROFILING_SUPPORTED
Expand Down
18 changes: 11 additions & 7 deletions Sources/Sentry/Profiling/SentryLaunchProfiling.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
SentryTracer *_Nullable sentry_launchTracer;

SentryTracerConfiguration *
sentry_config(
sentry_configForLaunchProfilerForTrace(
NSNumber *profilesRate, NSNumber *profilesRand, SentryProfileOptions *_Nullable profileOptions)
{
SentryTracerConfiguration *config = [SentryTracerConfiguration defaultConfiguration];
Expand Down Expand Up @@ -175,7 +175,7 @@
}

SentryTransactionContext *
sentry_context(NSNumber *tracesRate, NSNumber *tracesRand)
sentry_contextForLaunchProfilerForTrace(NSNumber *tracesRate, NSNumber *tracesRand)
{
SentryTransactionContext *context =
[[SentryTransactionContext alloc] initWithName:@"launch"
Expand Down Expand Up @@ -215,7 +215,7 @@
[SentryLog configure:YES diagnosticLevel:kSentryLevelDebug];
# endif // defined(DEBUG)

NSDictionary<NSString *, NSNumber *> *launchConfig = appLaunchProfileConfiguration();
NSDictionary<NSString *, NSNumber *> *launchConfig = sentry_appLaunchProfileConfiguration();
if ([launchConfig[kSentryLaunchProfileConfigKeyContinuousProfiling] boolValue]) {
SENTRY_LOG_DEBUG(@"Starting continuous launch profile.");
[SentryContinuousProfiler start];
Expand Down Expand Up @@ -280,10 +280,14 @@

SENTRY_LOG_INFO(@"Starting app launch trace profile at %llu.", getAbsoluteTime());
sentry_isTracingAppLaunch = YES;
sentry_launchTracer = [[SentryTracer alloc]
initWithTransactionContext:sentry_context(tracesRate, tracesRand)
hub:nil
configuration:sentry_config(profilesRate, profilesRand, profileOptions)];

SentryTransactionContext *context
= sentry_contextForLaunchProfilerForTrace(tracesRate, tracesRand);
SentryTracerConfiguration *config
= sentry_configForLaunchProfilerForTrace(profilesRate, profilesRand, profileOptions);
sentry_launchTracer = [[SentryTracer alloc] initWithTransactionContext:context
hub:nil
configuration:config];
}

# pragma mark - Public
Expand Down
32 changes: 15 additions & 17 deletions Sources/Sentry/Profiling/SentryProfiledTracerConcurrency.mm
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
_unsafe_cleanUpContinuousProfilerV2();
}

SentryId *_Nullable _sentry_startContinuousProfilerV2(
SentryId *_Nullable _sentry_startContinuousProfilerV2ForTrace(
SentryProfileOptions *profileOptions, SentryTransactionContext *transactionContext)
{
if (profileOptions.lifecycle != SentryProfileLifecycleTrace) {
Expand All @@ -138,7 +138,7 @@
} // namespace

void
sentry_trackProfilerForTracer(SentryProfiler *profiler, SentryId *internalTraceId)
sentry_trackTransactionProfilerForTrace(SentryProfiler *profiler, SentryId *internalTraceId)
{
std::lock_guard<std::mutex> l(_gStateLock);

Expand Down Expand Up @@ -166,24 +166,16 @@
}

void
sentry_discardProfilerHybrid(SentryId *internalTraceId, SentryHub *hub)
{
}

void
sentry_discardProfiler(
SentryId *internalTraceId, SentryHub *hub, BOOL launchTraceSampledForContinuousProfilingV2)
sentry_discardProfilerCorrelatedToTrace(SentryId *internalTraceId, SentryHub *hub, BOOL isProfiling)
{
std::lock_guard<std::mutex> l(_gStateLock);

if ([SentryContinuousProfiler isCurrentlyProfiling]) {
BOOL notLaunchContinuousProfileV2TraceLifecycle = hub != nil
&& hub.client.options.profiling != nil
&& hub.client.options.profiling.lifecycle == SentryProfileLifecycleTrace;
if (!notLaunchContinuousProfileV2TraceLifecycle
&& !launchTraceSampledForContinuousProfilingV2) {
SENTRY_LOG_DEBUG(@"The trace associated with the profiler was not sampled, so the "
@"profiler was never started and there is nothing to discard.");
if (!notLaunchContinuousProfileV2TraceLifecycle && !isProfiling) {
SENTRY_LOG_DEBUG(@"Continuous profiler v1 won't be stopped with a tracer.");
return;
}

Expand Down Expand Up @@ -326,17 +318,23 @@
}];
}

SentryId *_Nullable sentry_startProfiler(SentryTracerConfiguration *configuration, SentryHub *hub,
SentryTransactionContext *transactionContext)
SentryId *_Nullable sentry_startProfilerForTrace(SentryTracerConfiguration *configuration,
SentryHub *hub, SentryTransactionContext *transactionContext)
{
if (configuration.profileOptions != nil) {
return _sentry_startContinuousProfilerV2(configuration.profileOptions, transactionContext);
// launch profile; there's hub to get options from, so they're read from the launch profile
// config file and packaged into the tracer configuration in the launch profile codepath
return _sentry_startContinuousProfilerV2ForTrace(
configuration.profileOptions, transactionContext);
} else if ([hub.getClient.options isContinuousProfilingEnabled]) {
// non launch profile
SentryProfileOptions *profileOptions = hub.getClient.options.profiling;
if (profileOptions == nil) {
SENTRY_LOG_DEBUG(
@"Continuous profiling v1 configured; will not start automatically for trace.");
return nil;
}
return _sentry_startContinuousProfilerV2(profileOptions, transactionContext);
return _sentry_startContinuousProfilerV2ForTrace(profileOptions, transactionContext);
} else {
BOOL profileShouldBeSampled
= configuration.profilesSamplerDecision.decision == kSentrySampleDecisionYes;
Expand Down
4 changes: 2 additions & 2 deletions Sources/Sentry/Profiling/SentryTraceProfiler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ + (BOOL)startWithTracer:(SentryId *)traceId

if ([_threadUnsafe_gTraceProfiler isRunning]) {
SENTRY_LOG_DEBUG(@"A trace profiler is already running.");
sentry_trackProfilerForTracer(_threadUnsafe_gTraceProfiler, traceId);
sentry_trackTransactionProfilerForTrace(_threadUnsafe_gTraceProfiler, traceId);
// record a new metric sample for every concurrent span start
[_threadUnsafe_gTraceProfiler.metricProfiler recordMetrics];
return YES;
Expand All @@ -49,7 +49,7 @@ + (BOOL)startWithTracer:(SentryId *)traceId
}

_threadUnsafe_gTraceProfiler.profilerId = [[SentryId alloc] init];
sentry_trackProfilerForTracer(_threadUnsafe_gTraceProfiler, traceId);
sentry_trackTransactionProfilerForTrace(_threadUnsafe_gTraceProfiler, traceId);
}

[self scheduleTimeoutTimer];
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/SentryFileManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ - (BOOL)isDirectory:(NSString *)path
return sentryLaunchConfigFileURL;
}

NSDictionary<NSString *, NSNumber *> *_Nullable appLaunchProfileConfiguration(void)
NSDictionary<NSString *, NSNumber *> *_Nullable sentry_appLaunchProfileConfiguration(void)
{
NSURL *url = launchProfileConfigFileURL();
if (![[NSFileManager defaultManager] fileExistsAtPath:url.path]) {
Expand Down
5 changes: 2 additions & 3 deletions Sources/Sentry/SentryTracer.m
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ - (instancetype)initWithTransactionContext:(SentryTransactionContext *)transacti
#endif // SENTRY_HAS_UIKIT

#if SENTRY_TARGET_PROFILING_SUPPORTED
_profilerReferenceID = sentry_startProfiler(configuration, hub, transactionContext);
_profilerReferenceID = sentry_startProfilerForTrace(configuration, hub, transactionContext);
_isProfiling = _profilerReferenceID != nil;
#endif // SENTRY_TARGET_PROFILING_SUPPORTED

Expand All @@ -191,8 +191,7 @@ - (instancetype)initWithTransactionContext:(SentryTransactionContext *)transacti
- (void)dealloc
{
#if SENTRY_TARGET_PROFILING_SUPPORTED
sentry_discardProfiler(_profilerReferenceID, self.hub,
self.isProfiling /* launchTraceSampledForContinuousProfilingV2 */);
sentry_discardProfilerCorrelatedToTrace(_profilerReferenceID, self.hub, self.isProfiling);
#endif // SENTRY_TARGET_PROFILING_SUPPORTED
[self cancelDeadlineTimeout];
}
Expand Down
3 changes: 1 addition & 2 deletions Sources/Sentry/include/HybridPublic/PrivateSentrySDKOnly.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ typedef void (^SentryOnAppStartMeasurementAvailable)(
* associated with this profiler was sampled for proper bookkeeping to align automatic continuous
* profiling to root spans, and provide the configuration options.
*/
+ (void)discardProfilerForTrace:(SentryId *)traceId
traceSampled:(BOOL)launchTraceSampledForContinuousProfilingV2;
+ (void)discardProfilerForTrace:(SentryId *)traceId traceSampled:(BOOL)isProfiling;
#endif // SENTRY_TARGET_PROFILING_SUPPORTED

@property (class, nullable, nonatomic, copy)
Expand Down
3 changes: 2 additions & 1 deletion Sources/Sentry/include/SentryFileManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ SENTRY_EXTERN BOOL appLaunchProfileConfigFileExists(void);
* Retrieve the contents of the launch profile config file, which stores the sample rates used to
* decide whether or not to profile this launch.
*/
SENTRY_EXTERN NSDictionary<NSString *, NSNumber *> *_Nullable appLaunchProfileConfiguration(void);
SENTRY_EXTERN NSDictionary<NSString *, NSNumber *> *_Nullable sentry_appLaunchProfileConfiguration(
void);

/**
* Write a config file that stores the sample rates used to determine whether this launch should
Expand Down
12 changes: 5 additions & 7 deletions Sources/Sentry/include/SentryProfiledTracerConcurrency.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ void sentry_captureTransactionWithProfile(SentryHub *hub, SentryDispatchQueueWra
* @Returns An ID to use as a unique, unchanging ID for the tracer that started the profiler. It's
* different from the profiler's internal ID.
*/
SentryId *_Nullable sentry_startProfiler(SentryTracerConfiguration *configuration, SentryHub *hub,
SentryTransactionContext *transactionContext);
SentryId *_Nullable sentry_startProfilerForTrace(SentryTracerConfiguration *configuration,
SentryHub *hub, SentryTransactionContext *transactionContext);

/**
* @note Only called for transaction-based profiling or continuous profiling V2 with trace lifecycle
Expand All @@ -52,16 +52,14 @@ SENTRY_EXTERN void sentry_stopProfilerDueToFinishedTransaction(
* Associate the provided profiler and tracer so that profiling data may be retrieved by the tracer
* when it is ready to transmit its envelope.
*/
void sentry_trackProfilerForTracer(SentryProfiler *profiler, SentryId *internalTraceId);

void sentry_discardProfilerHybrid(SentryId *internalTraceId, SentryHub *hub);
void sentry_trackTransactionProfilerForTrace(SentryProfiler *profiler, SentryId *internalTraceId);

/**
* For transactions that will be discarded, clean up the bookkeeping state associated with them to
* reclaim the memory they're using.
*/
void sentry_discardProfiler(
SentryId *internalTraceId, SentryHub *hub, BOOL launchTraceSampledForContinuousProfilingV2);
void sentry_discardProfilerCorrelatedToTrace(
SentryId *internalTraceId, SentryHub *hub, BOOL isProfiling);

/**
* Return the profiler instance associated with the tracer. If it was the last tracer for the
Expand Down
Loading
Loading