Skip to content

Commit d21e64c

Browse files
authored
ref(profiling): function renames (#5007)
1 parent b8d0e7d commit d21e64c

12 files changed

+89
-89
lines changed

SentryTestUtils/SentryLaunchProfiling+Tests.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ BOOL sentry_willProfileNextLaunch(SentryOptions *options);
4343
*/
4444
void _sentry_nondeduplicated_startLaunchProfile(void);
4545

46-
SentryTransactionContext *sentry_context(NSNumber *tracesRate, NSNumber *tracesRand);
46+
SentryTransactionContext *sentry_contextForLaunchProfilerForTrace(
47+
NSNumber *tracesRate, NSNumber *tracesRand);
4748

4849
NS_ASSUME_NONNULL_END
4950

Sources/Sentry/PrivateSentrySDKOnly.mm

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,9 @@ + (uint64_t)startProfilerForTrace:(SentryId *)traceId;
224224
return payload;
225225
}
226226

227-
+ (void)discardProfilerForTrace:(SentryId *)traceId
228-
traceSampled:(BOOL)launchTraceSampledForContinuousProfilingV2;
227+
+ (void)discardProfilerForTrace:(SentryId *)traceId traceSampled:(BOOL)isProfiling;
229228
{
230-
sentry_discardProfiler(
231-
traceId, SentrySDK.currentHub, launchTraceSampledForContinuousProfilingV2);
229+
sentry_discardProfilerCorrelatedToTrace(traceId, SentrySDK.currentHub, isProfiling);
232230
}
233231

234232
#endif // SENTRY_TARGET_PROFILING_SUPPORTED

Sources/Sentry/Profiling/SentryLaunchProfiling.m

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
SentryTracer *_Nullable sentry_launchTracer;
4343

4444
SentryTracerConfiguration *
45-
sentry_config(
45+
sentry_configForLaunchProfilerForTrace(
4646
NSNumber *profilesRate, NSNumber *profilesRand, SentryProfileOptions *_Nullable profileOptions)
4747
{
4848
SentryTracerConfiguration *config = [SentryTracerConfiguration defaultConfiguration];
@@ -175,7 +175,7 @@
175175
}
176176

177177
SentryTransactionContext *
178-
sentry_context(NSNumber *tracesRate, NSNumber *tracesRand)
178+
sentry_contextForLaunchProfilerForTrace(NSNumber *tracesRate, NSNumber *tracesRand)
179179
{
180180
SentryTransactionContext *context =
181181
[[SentryTransactionContext alloc] initWithName:@"launch"
@@ -215,7 +215,7 @@
215215
[SentryLog configure:YES diagnosticLevel:kSentryLevelDebug];
216216
# endif // defined(DEBUG)
217217

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

281281
SENTRY_LOG_INFO(@"Starting app launch trace profile at %llu.", getAbsoluteTime());
282282
sentry_isTracingAppLaunch = YES;
283-
sentry_launchTracer = [[SentryTracer alloc]
284-
initWithTransactionContext:sentry_context(tracesRate, tracesRand)
285-
hub:nil
286-
configuration:sentry_config(profilesRate, profilesRand, profileOptions)];
283+
284+
SentryTransactionContext *context
285+
= sentry_contextForLaunchProfilerForTrace(tracesRate, tracesRand);
286+
SentryTracerConfiguration *config
287+
= sentry_configForLaunchProfilerForTrace(profilesRate, profilesRand, profileOptions);
288+
sentry_launchTracer = [[SentryTracer alloc] initWithTransactionContext:context
289+
hub:nil
290+
configuration:config];
287291
}
288292

289293
# pragma mark - Public

Sources/Sentry/Profiling/SentryProfiledTracerConcurrency.mm

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
_unsafe_cleanUpContinuousProfilerV2();
118118
}
119119

120-
SentryId *_Nullable _sentry_startContinuousProfilerV2(
120+
SentryId *_Nullable _sentry_startContinuousProfilerV2ForTrace(
121121
SentryProfileOptions *profileOptions, SentryTransactionContext *transactionContext)
122122
{
123123
if (profileOptions.lifecycle != SentryProfileLifecycleTrace) {
@@ -138,7 +138,7 @@
138138
} // namespace
139139

140140
void
141-
sentry_trackProfilerForTracer(SentryProfiler *profiler, SentryId *internalTraceId)
141+
sentry_trackTransactionProfilerForTrace(SentryProfiler *profiler, SentryId *internalTraceId)
142142
{
143143
std::lock_guard<std::mutex> l(_gStateLock);
144144

@@ -166,24 +166,16 @@
166166
}
167167

168168
void
169-
sentry_discardProfilerHybrid(SentryId *internalTraceId, SentryHub *hub)
170-
{
171-
}
172-
173-
void
174-
sentry_discardProfiler(
175-
SentryId *internalTraceId, SentryHub *hub, BOOL launchTraceSampledForContinuousProfilingV2)
169+
sentry_discardProfilerCorrelatedToTrace(SentryId *internalTraceId, SentryHub *hub, BOOL isProfiling)
176170
{
177171
std::lock_guard<std::mutex> l(_gStateLock);
178172

179173
if ([SentryContinuousProfiler isCurrentlyProfiling]) {
180174
BOOL notLaunchContinuousProfileV2TraceLifecycle = hub != nil
181175
&& hub.client.options.profiling != nil
182176
&& hub.client.options.profiling.lifecycle == SentryProfileLifecycleTrace;
183-
if (!notLaunchContinuousProfileV2TraceLifecycle
184-
&& !launchTraceSampledForContinuousProfilingV2) {
185-
SENTRY_LOG_DEBUG(@"The trace associated with the profiler was not sampled, so the "
186-
@"profiler was never started and there is nothing to discard.");
177+
if (!notLaunchContinuousProfileV2TraceLifecycle && !isProfiling) {
178+
SENTRY_LOG_DEBUG(@"Continuous profiler v1 won't be stopped with a tracer.");
187179
return;
188180
}
189181

@@ -326,17 +318,23 @@
326318
}];
327319
}
328320

329-
SentryId *_Nullable sentry_startProfiler(SentryTracerConfiguration *configuration, SentryHub *hub,
330-
SentryTransactionContext *transactionContext)
321+
SentryId *_Nullable sentry_startProfilerForTrace(SentryTracerConfiguration *configuration,
322+
SentryHub *hub, SentryTransactionContext *transactionContext)
331323
{
332324
if (configuration.profileOptions != nil) {
333-
return _sentry_startContinuousProfilerV2(configuration.profileOptions, transactionContext);
325+
// launch profile; there's hub to get options from, so they're read from the launch profile
326+
// config file and packaged into the tracer configuration in the launch profile codepath
327+
return _sentry_startContinuousProfilerV2ForTrace(
328+
configuration.profileOptions, transactionContext);
334329
} else if ([hub.getClient.options isContinuousProfilingEnabled]) {
330+
// non launch profile
335331
SentryProfileOptions *profileOptions = hub.getClient.options.profiling;
336332
if (profileOptions == nil) {
333+
SENTRY_LOG_DEBUG(
334+
@"Continuous profiling v1 configured; will not start automatically for trace.");
337335
return nil;
338336
}
339-
return _sentry_startContinuousProfilerV2(profileOptions, transactionContext);
337+
return _sentry_startContinuousProfilerV2ForTrace(profileOptions, transactionContext);
340338
} else {
341339
BOOL profileShouldBeSampled
342340
= configuration.profilesSamplerDecision.decision == kSentrySampleDecisionYes;

Sources/Sentry/Profiling/SentryTraceProfiler.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ + (BOOL)startWithTracer:(SentryId *)traceId
3535

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

5151
_threadUnsafe_gTraceProfiler.profilerId = [[SentryId alloc] init];
52-
sentry_trackProfilerForTracer(_threadUnsafe_gTraceProfiler, traceId);
52+
sentry_trackTransactionProfilerForTrace(_threadUnsafe_gTraceProfiler, traceId);
5353
}
5454

5555
[self scheduleTimeoutTimer];

Sources/Sentry/SentryFileManager.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ - (BOOL)isDirectory:(NSString *)path
672672
return sentryLaunchConfigFileURL;
673673
}
674674

675-
NSDictionary<NSString *, NSNumber *> *_Nullable appLaunchProfileConfiguration(void)
675+
NSDictionary<NSString *, NSNumber *> *_Nullable sentry_appLaunchProfileConfiguration(void)
676676
{
677677
NSURL *url = launchProfileConfigFileURL();
678678
if (![[NSFileManager defaultManager] fileExistsAtPath:url.path]) {

Sources/Sentry/SentryTracer.m

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ - (instancetype)initWithTransactionContext:(SentryTransactionContext *)transacti
179179
#endif // SENTRY_HAS_UIKIT
180180

181181
#if SENTRY_TARGET_PROFILING_SUPPORTED
182-
_profilerReferenceID = sentry_startProfiler(configuration, hub, transactionContext);
182+
_profilerReferenceID = sentry_startProfilerForTrace(configuration, hub, transactionContext);
183183
_isProfiling = _profilerReferenceID != nil;
184184
#endif // SENTRY_TARGET_PROFILING_SUPPORTED
185185

@@ -191,8 +191,7 @@ - (instancetype)initWithTransactionContext:(SentryTransactionContext *)transacti
191191
- (void)dealloc
192192
{
193193
#if SENTRY_TARGET_PROFILING_SUPPORTED
194-
sentry_discardProfiler(_profilerReferenceID, self.hub,
195-
self.isProfiling /* launchTraceSampledForContinuousProfilingV2 */);
194+
sentry_discardProfilerCorrelatedToTrace(_profilerReferenceID, self.hub, self.isProfiling);
196195
#endif // SENTRY_TARGET_PROFILING_SUPPORTED
197196
[self cancelDeadlineTimeout];
198197
}

Sources/Sentry/include/HybridPublic/PrivateSentrySDKOnly.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,7 @@ typedef void (^SentryOnAppStartMeasurementAvailable)(
125125
* associated with this profiler was sampled for proper bookkeeping to align automatic continuous
126126
* profiling to root spans, and provide the configuration options.
127127
*/
128-
+ (void)discardProfilerForTrace:(SentryId *)traceId
129-
traceSampled:(BOOL)launchTraceSampledForContinuousProfilingV2;
128+
+ (void)discardProfilerForTrace:(SentryId *)traceId traceSampled:(BOOL)isProfiling;
130129
#endif // SENTRY_TARGET_PROFILING_SUPPORTED
131130

132131
@property (class, nullable, nonatomic, copy)

Sources/Sentry/include/SentryFileManager.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ SENTRY_EXTERN BOOL appLaunchProfileConfigFileExists(void);
143143
* Retrieve the contents of the launch profile config file, which stores the sample rates used to
144144
* decide whether or not to profile this launch.
145145
*/
146-
SENTRY_EXTERN NSDictionary<NSString *, NSNumber *> *_Nullable appLaunchProfileConfiguration(void);
146+
SENTRY_EXTERN NSDictionary<NSString *, NSNumber *> *_Nullable sentry_appLaunchProfileConfiguration(
147+
void);
147148

148149
/**
149150
* Write a config file that stores the sample rates used to determine whether this launch should

Sources/Sentry/include/SentryProfiledTracerConcurrency.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ void sentry_captureTransactionWithProfile(SentryHub *hub, SentryDispatchQueueWra
3232
* @Returns An ID to use as a unique, unchanging ID for the tracer that started the profiler. It's
3333
* different from the profiler's internal ID.
3434
*/
35-
SentryId *_Nullable sentry_startProfiler(SentryTracerConfiguration *configuration, SentryHub *hub,
36-
SentryTransactionContext *transactionContext);
35+
SentryId *_Nullable sentry_startProfilerForTrace(SentryTracerConfiguration *configuration,
36+
SentryHub *hub, SentryTransactionContext *transactionContext);
3737

3838
/**
3939
* @note Only called for transaction-based profiling or continuous profiling V2 with trace lifecycle
@@ -52,16 +52,14 @@ SENTRY_EXTERN void sentry_stopProfilerDueToFinishedTransaction(
5252
* Associate the provided profiler and tracer so that profiling data may be retrieved by the tracer
5353
* when it is ready to transmit its envelope.
5454
*/
55-
void sentry_trackProfilerForTracer(SentryProfiler *profiler, SentryId *internalTraceId);
56-
57-
void sentry_discardProfilerHybrid(SentryId *internalTraceId, SentryHub *hub);
55+
void sentry_trackTransactionProfilerForTrace(SentryProfiler *profiler, SentryId *internalTraceId);
5856

5957
/**
6058
* For transactions that will be discarded, clean up the bookkeeping state associated with them to
6159
* reclaim the memory they're using.
6260
*/
63-
void sentry_discardProfiler(
64-
SentryId *internalTraceId, SentryHub *hub, BOOL launchTraceSampledForContinuousProfilingV2);
61+
void sentry_discardProfilerCorrelatedToTrace(
62+
SentryId *internalTraceId, SentryHub *hub, BOOL isProfiling);
6563

6664
/**
6765
* Return the profiler instance associated with the tracer. If it was the last tracer for the

0 commit comments

Comments
 (0)