Skip to content

Commit e29a276

Browse files
committed
Fix
1 parent 3b450bc commit e29a276

File tree

127 files changed

+919
-1875
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+919
-1875
lines changed

Samples/iOS-Swift/iOS-Swift/Profiling/ProfilingViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Sentry
1+
@_spi(Private) import Sentry
22
import SentrySampleShared
33
import UIKit
44

Samples/iOS-Swift/iOS-Swift/Tools/SentryExposure.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#import <Sentry/SentryScope.h>
33
#import <UIKit/UIKit.h>
44

5-
@class SentryOptionsInternal;
5+
@class SentryOptions;
66

77
NS_ASSUME_NONNULL_BEGIN
88

Samples/iOS-Swift/iOS-Swift/Tools/iOS-Swift-Bridging-Header.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33
#import "SentryExposure.h"
44
#import <Sentry/PrivateSentrySDKOnly.h>
55
#import <Sentry/SentryDsn+Private.h>
6-
#import <Sentry/SentryOptionsInternal+Private.h>

Sentry.xcodeproj/project.pbxproj

Lines changed: 13 additions & 29 deletions
Large diffs are not rendered by default.

SentryTestUtils/Headers/SentryLaunchProfiling+Tests.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# import "SentryDefines.h"
66
# import "SentryProfiler+Private.h"
77

8-
@class SentryOptionsInternal;
8+
@class SentryOptions;
99
@class SentrySamplerDecision;
1010

1111
NS_ASSUME_NONNULL_BEGIN
@@ -15,7 +15,7 @@ NS_ASSUME_NONNULL_BEGIN
1515
* expressible in Swift. This wraps it and only returns the `BOOL shouldProfile` value in the
1616
* struct.
1717
*/
18-
BOOL sentry_willProfileNextLaunch(SentryOptionsInternal *options);
18+
BOOL sentry_willProfileNextLaunch(SentryOptions *options);
1919

2020
/**
2121
* Contains the logic to start a launch profile. Exposed separately from @c

SentryTestUtils/Sources/TestClient.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import _SentryPrivate
22
import Foundation
3-
@_spi(Private) @testable import Sentry
3+
@_spi(Private) import Sentry
44

55
public class TestClient: SentryClientInternal {
6-
public override init?(options: SentryOptionsInternal) {
6+
public override init?(options: NSObject) {
77
super.init(
88
options: options,
9-
transportAdapter: TestTransportAdapter(transports: [TestTransport()], options: options),
9+
transportAdapter: TestTransportAdapter(transports: [TestTransport()], options: options as! Options),
1010
fileManager: try! TestFileManager(
1111
options: options.toOptions(),
1212
dateProvider: TestCurrentDateProvider(),
@@ -22,7 +22,7 @@ public class TestClient: SentryClientInternal {
2222

2323
// Without this override we get a fatal error: use of unimplemented initializer
2424
// see https://stackoverflow.com/questions/28187261/ios-swift-fatal-error-use-of-unimplemented-initializer-init
25-
@_spi(Private) public override init(options: SentryOptionsInternal, transportAdapter: SentryTransportAdapter, fileManager: SentryFileManager, threadInspector: SentryDefaultThreadInspector, debugImageProvider: SentryDebugImageProvider, random: SentryRandomProtocol, locale: Locale, timezone: TimeZone) {
25+
@_spi(Private) public override init(options: NSObject, transportAdapter: SentryTransportAdapter, fileManager: SentryFileManager, threadInspector: SentryDefaultThreadInspector, debugImageProvider: SentryDebugImageProvider, random: SentryRandomProtocol, locale: Locale, timezone: TimeZone) {
2626
super.init(
2727
options: options,
2828
transportAdapter: transportAdapter,

Sources/Resources/Sentry.modulemap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ framework module Sentry {
1111
header "SentryAppStartMeasurement.h"
1212
header "SentryBreadcrumb+Private.h"
1313
header "SentryFormatter.h"
14+
header "SentryOptionsInternal.h"
1415
header "SentrySwizzle.h"
1516
header "SentryUser+Private.h"
1617

Sources/Sentry/Profiling/SentryProfilingSwiftHelpers.m

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@
22
#if SENTRY_TARGET_PROFILING_SUPPORTED
33

44
# import "SentryClient.h"
5+
# import "SentryDependencyContainerSwiftHelper.h"
6+
# import "SentryHub.h"
7+
# import "SentryInternalDefines.h"
8+
# import "SentryLaunchProfiling.h"
59
# import "SentryLogC.h"
10+
# import "SentryProfileConfiguration.h"
611
# import "SentryProfiler+Private.h"
12+
# import "SentrySDK+Private.h"
713
# import "SentrySamplerDecision.h"
814
# import "SentrySwift.h"
915

@@ -158,6 +164,16 @@
158164
}
159165

160166
# if SENTRY_HAS_UIKIT
167+
BOOL
168+
sentry_appHangsDisabled(void)
169+
{
170+
return [[[[SentrySDKInternal currentHub] getClient] options] isAppHangTrackingDisabled];
171+
}
172+
BOOL
173+
sentry_autoPerformanceTracingDisabled(void)
174+
{
175+
return ![[[[SentrySDKInternal currentHub] getClient] options] enableAutoPerformanceTracing];
176+
}
161177
void
162178
sentry_startFramesTracker(void)
163179
{
@@ -183,3 +199,91 @@
183199
}
184200
# endif // SENTRY_HAS_UIKIT
185201
#endif // SENTRY_TARGET_PROFILING_SUPPORTED
202+
203+
void
204+
sentry_configureContinuousProfiling(SentryOptions *options)
205+
{
206+
if (options.configureProfiling == nil) {
207+
SENTRY_LOG_DEBUG(@"Continuous profiling V2 configuration not set by SDK consumer, nothing "
208+
@"to do here.");
209+
return;
210+
}
211+
212+
SentryProfileOptions *_Nonnull profilingOptions = sentry_getSentryProfileOptions();
213+
options.profiling = profilingOptions;
214+
options.configureProfiling(profilingOptions);
215+
216+
if (sentry_isTraceLifecycle(profilingOptions) && !options.isTracingEnabled) {
217+
SENTRY_LOG_WARN(
218+
@"Tracing must be enabled in order to configure profiling with trace lifecycle.");
219+
return;
220+
}
221+
222+
// if a launch profiler was started, sentry_profileConfiguration will have been set at that time
223+
// with the hydrated options that were persisted from the previous SDK start, which are used to
224+
// help determine when/how to stop the launch profile. otherwise, there won't yet be a
225+
// SentryProfileConfiguration instance, so we'll instantiate one which will be used to access
226+
// the profile session sample rate henceforth
227+
if (sentry_profileConfiguration == nil) {
228+
sentry_profileConfiguration =
229+
[[SentryProfileConfiguration alloc] initWithProfileOptions:profilingOptions];
230+
}
231+
232+
sentry_reevaluateSessionSampleRate();
233+
234+
SENTRY_LOG_DEBUG(@"Configured profiling options: <%@: {\n lifecycle: %@\n sessionSampleRate: "
235+
@"%.2f\n profileAppStarts: %@\n}",
236+
options.profiling, sentry_isTraceLifecycle(profilingOptions) ? @"trace" : @"manual",
237+
sentry_sessionSampleRate(profilingOptions),
238+
sentry_profileAppStarts(profilingOptions) ? @"YES" : @"NO");
239+
}
240+
241+
void
242+
sentry_sdkInitProfilerTasks(SentryOptions *options, SentryHubInternal *hub)
243+
{
244+
// get the configuration options from the last time the launch config was written; it may be
245+
// different than the new options the SDK was just started with
246+
SentryProfileConfiguration *configurationFromLaunch = sentry_profileConfiguration;
247+
248+
sentry_configureContinuousProfiling(options);
249+
250+
sentry_dispatchAsync(SentryDependencyContainerSwiftHelper.dispatchQueueWrapper, ^{
251+
if (configurationFromLaunch.isProfilingThisLaunch) {
252+
BOOL shouldStopAndTransmitLaunchProfile = YES;
253+
254+
BOOL profileIsContinuousV2 = configurationFromLaunch.profileOptions != nil;
255+
BOOL v2LifecycleIsManual = profileIsContinuousV2
256+
&& !sentry_isTraceLifecycle(SENTRY_UNWRAP_NULLABLE(
257+
SentryProfileOptions, configurationFromLaunch.profileOptions));
258+
259+
#if SENTRY_HAS_UIKIT
260+
BOOL v2LifecycleIsTrace = profileIsContinuousV2
261+
&& sentry_isTraceLifecycle(SENTRY_UNWRAP_NULLABLE(
262+
SentryProfileOptions, configurationFromLaunch.profileOptions));
263+
BOOL profileIsCorrelatedToTrace = !profileIsContinuousV2 || v2LifecycleIsTrace;
264+
if (profileIsCorrelatedToTrace && configurationFromLaunch.waitForFullDisplay) {
265+
SENTRY_LOG_DEBUG(
266+
@"Will wait to stop launch profile correlated to a trace until full "
267+
@"display reported.");
268+
shouldStopAndTransmitLaunchProfile = NO;
269+
}
270+
#endif // SENTRY_HAS_UIKIT
271+
272+
if (v2LifecycleIsManual) {
273+
SENTRY_LOG_DEBUG(@"Continuous manual launch profiles aren't stopped on calls to "
274+
@"SentrySDK.start, "
275+
@"not stopping profile.");
276+
shouldStopAndTransmitLaunchProfile = NO;
277+
}
278+
279+
if (shouldStopAndTransmitLaunchProfile) {
280+
SENTRY_LOG_DEBUG(
281+
@"Stopping launch profile in SentrySDK.start because there is no time "
282+
@"to display tracker to stop it.");
283+
sentry_stopAndDiscardLaunchProfileTracer(hub);
284+
}
285+
}
286+
287+
sentry_configureLaunchProfilingForNextLaunch(options);
288+
});
289+
}

Sources/Sentry/Public/SentryDefines.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,6 @@ typedef SentryEvent *_Nullable (^SentryBeforeSendEventCallback)(SentryEvent *_No
102102
*/
103103
typedef id<SentrySpan> _Nullable (^SentryBeforeSendSpanCallback)(id<SentrySpan> _Nonnull span);
104104

105-
/**
106-
* Use this block to drop or modify a log before the SDK sends it to Sentry. Return @c nil to drop
107-
* the log.
108-
*/
109-
typedef SentryLog *_Nullable (^SentryBeforeSendLogCallback)(SentryLog *_Nonnull log);
110-
111105
/**
112106
* Block can be used to decide if the SDK should capture a screenshot or not. Return @c true if the
113107
* SDK should capture a screenshot, return @c false if not. This callback doesn't work for crashes.

Sources/Sentry/Public/SentryDsn.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ NS_ASSUME_NONNULL_BEGIN
66

77
@property (nonatomic, strong, readonly) NSURL *url;
88

9-
- (_Nullable instancetype)initWithString:(NSString *)dsnString
9+
- (_Nullable instancetype)initWithString:(NSString *_Nullable)dsnString
1010
didFailWithError:(NSError *_Nullable *_Nullable)error;
1111

1212
- (NSURL *)getEnvelopeEndpoint;

0 commit comments

Comments
 (0)