Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Sentry
@_spi(Private) import Sentry
import SentrySampleShared
import UIKit

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
#import "SentryExposure.h"
#import <Sentry/PrivateSentrySDKOnly.h>
#import <Sentry/SentryDsn+Private.h>
#import <Sentry/SentryOptions+Private.h>
40 changes: 18 additions & 22 deletions Sentry.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions SentryTestUtils/Sources/TestClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import Foundation
@_spi(Private) import Sentry

public class TestClient: SentryClientInternal {
public override init?(options: Options) {
public override init?(options: NSObject) {
super.init(
options: options,
transportAdapter: TestTransportAdapter(transports: [TestTransport()], options: options),
transportAdapter: TestTransportAdapter(transports: [TestTransport()], options: options as! Options),
fileManager: try! TestFileManager(
options: options,
options: options.toOptions(),
dateProvider: TestCurrentDateProvider(),
dispatchQueueWrapper: TestSentryDispatchQueueWrapper()
),
Expand All @@ -22,7 +22,7 @@ public class TestClient: SentryClientInternal {

// Without this override we get a fatal error: use of unimplemented initializer
// see https://stackoverflow.com/questions/28187261/ios-swift-fatal-error-use-of-unimplemented-initializer-init
@_spi(Private) public override init(options: Options, transportAdapter: SentryTransportAdapter, fileManager: SentryFileManager, threadInspector: SentryDefaultThreadInspector, debugImageProvider: SentryDebugImageProvider, random: SentryRandomProtocol, locale: Locale, timezone: TimeZone) {
@_spi(Private) public override init(options: NSObject, transportAdapter: SentryTransportAdapter, fileManager: SentryFileManager, threadInspector: SentryDefaultThreadInspector, debugImageProvider: SentryDebugImageProvider, random: SentryRandomProtocol, locale: Locale, timezone: TimeZone) {
super.init(
options: options,
transportAdapter: transportAdapter,
Expand Down
1 change: 0 additions & 1 deletion Sources/Sentry/PrivateSentrySDKOnly.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#import "SentryInstallation.h"
#import "SentryInternalDefines.h"
#import "SentryMeta.h"
#import "SentryOptions+Private.h"
#import "SentryProfileCollector.h"
#import "SentryPropagationContext.h"
#import "SentrySDK+Private.h"
Expand Down
1 change: 0 additions & 1 deletion Sources/Sentry/Profiling/SentryLaunchProfiling.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# import "SentryInternalDefines.h"
# import "SentryLaunchProfiling.h"
# import "SentryLogC.h"
# import "SentryOptions+Private.h"
# import "SentryProfileConfiguration.h"
# import "SentryProfiler+Private.h"
# import "SentrySamplerDecision.h"
Expand Down
2 changes: 0 additions & 2 deletions Sources/Sentry/Profiling/SentryProfiledTracerConcurrency.mm
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
# import "SentryContinuousProfiler.h"
# import "SentryInternalDefines.h"
# import "SentryLogC.h"
# import "SentryOptions+Private.h"
# import "SentryProfiler+Private.h"
# include <mutex>

# import "SentryEvent+Private.h"
# import "SentryHub+Private.h"
# import "SentryInternalDefines.h"
# import "SentryLaunchProfiling.h"
# import "SentryOptions+Private.h"
# import "SentryProfileConfiguration.h"
# import "SentryProfiledTracerConcurrency.h"
# import "SentryProfiler+Private.h"
Expand Down
106 changes: 105 additions & 1 deletion Sources/Sentry/Profiling/SentryProfilingSwiftHelpers.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
#if SENTRY_TARGET_PROFILING_SUPPORTED

# import "SentryClient.h"
# import "SentryDependencyContainerSwiftHelper.h"
# import "SentryHub.h"
# import "SentryInternalDefines.h"
# import "SentryLaunchProfiling.h"
# import "SentryLogC.h"
# import "SentryOptions+Private.h"
# import "SentryProfileConfiguration.h"
# import "SentryProfiler+Private.h"
# import "SentrySDK+Private.h"
# import "SentrySamplerDecision.h"
# import "SentrySwift.h"

Expand Down Expand Up @@ -159,6 +164,16 @@
}

# if SENTRY_HAS_UIKIT
BOOL
sentry_appHangsDisabled(void)
{
return [[[[SentrySDKInternal currentHub] getClient] options] isAppHangTrackingDisabled];
}
BOOL
sentry_autoPerformanceTracingDisabled(void)
{
return ![[[[SentrySDKInternal currentHub] getClient] options] enableAutoPerformanceTracing];
}
void
sentry_startFramesTracker(void)
{
Expand All @@ -183,4 +198,93 @@
return [SentryDependencyContainer.sharedInstance.framesTracker currentFrames];
}
# endif // SENTRY_HAS_UIKIT

void
sentry_configureContinuousProfiling(SentryOptions *options)
{
if (options.configureProfiling == nil) {
SENTRY_LOG_DEBUG(@"Continuous profiling V2 configuration not set by SDK consumer, nothing "
@"to do here.");
return;
}

SentryProfileOptions *_Nonnull profilingOptions = sentry_getSentryProfileOptions();
options.profiling = profilingOptions;
options.configureProfiling(profilingOptions);

if (sentry_isTraceLifecycle(profilingOptions) && !options.isTracingEnabled) {
SENTRY_LOG_WARN(
@"Tracing must be enabled in order to configure profiling with trace lifecycle.");
return;
}

// if a launch profiler was started, sentry_profileConfiguration will have been set at that time
// with the hydrated options that were persisted from the previous SDK start, which are used to
// help determine when/how to stop the launch profile. otherwise, there won't yet be a
// SentryProfileConfiguration instance, so we'll instantiate one which will be used to access
// the profile session sample rate henceforth
if (sentry_profileConfiguration == nil) {
sentry_profileConfiguration =
[[SentryProfileConfiguration alloc] initWithProfileOptions:profilingOptions];
}

sentry_reevaluateSessionSampleRate();

SENTRY_LOG_DEBUG(@"Configured profiling options: <%@: {\n lifecycle: %@\n sessionSampleRate: "
@"%.2f\n profileAppStarts: %@\n}",
options.profiling, sentry_isTraceLifecycle(profilingOptions) ? @"trace" : @"manual",
sentry_sessionSampleRate(profilingOptions),
sentry_profileAppStarts(profilingOptions) ? @"YES" : @"NO");
}

void
sentry_sdkInitProfilerTasks(SentryOptions *options, SentryHubInternal *hub)
{
// get the configuration options from the last time the launch config was written; it may be
// different than the new options the SDK was just started with
SentryProfileConfiguration *configurationFromLaunch = sentry_profileConfiguration;

sentry_configureContinuousProfiling(options);

sentry_dispatchAsync(SentryDependencyContainerSwiftHelper.dispatchQueueWrapper, ^{
if (configurationFromLaunch.isProfilingThisLaunch) {
BOOL shouldStopAndTransmitLaunchProfile = YES;

BOOL profileIsContinuousV2 = configurationFromLaunch.profileOptions != nil;
BOOL v2LifecycleIsManual = profileIsContinuousV2
&& !sentry_isTraceLifecycle(SENTRY_UNWRAP_NULLABLE(
SentryProfileOptions, configurationFromLaunch.profileOptions));

# if SENTRY_HAS_UIKIT
BOOL v2LifecycleIsTrace = profileIsContinuousV2
&& sentry_isTraceLifecycle(SENTRY_UNWRAP_NULLABLE(
SentryProfileOptions, configurationFromLaunch.profileOptions));
BOOL profileIsCorrelatedToTrace = !profileIsContinuousV2 || v2LifecycleIsTrace;
if (profileIsCorrelatedToTrace && configurationFromLaunch.waitForFullDisplay) {
SENTRY_LOG_DEBUG(
@"Will wait to stop launch profile correlated to a trace until full "
@"display reported.");
shouldStopAndTransmitLaunchProfile = NO;
}
# endif // SENTRY_HAS_UIKIT

if (v2LifecycleIsManual) {
SENTRY_LOG_DEBUG(@"Continuous manual launch profiles aren't stopped on calls to "
@"SentrySDK.start, "
@"not stopping profile.");
shouldStopAndTransmitLaunchProfile = NO;
}

if (shouldStopAndTransmitLaunchProfile) {
SENTRY_LOG_DEBUG(
@"Stopping launch profile in SentrySDK.start because there is no time "
@"to display tracker to stop it.");
sentry_stopAndDiscardLaunchProfileTracer(hub);
}
}

sentry_configureLaunchProfilingForNextLaunch(options);
});
}

#endif // SENTRY_TARGET_PROFILING_SUPPORTED
2 changes: 1 addition & 1 deletion Sources/Sentry/Public/Sentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ FOUNDATION_EXPORT const unsigned char SentryVersionString[];
# import <Sentry/SentryMechanismContext.h>
# import <Sentry/SentryMessage.h>
# import <Sentry/SentryNSError.h>
# import <Sentry/SentryOptions.h>
# import <Sentry/SentryProfilingConditionals.h>
# import <Sentry/SentryReplayApi.h>
# import <Sentry/SentryRequest.h>
# import <Sentry/SentrySampleDecision.h>
Expand Down
8 changes: 0 additions & 8 deletions Sources/Sentry/Public/SentryDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,6 @@ typedef SentryEvent *_Nullable (^SentryBeforeSendEventCallback)(SentryEvent *_No
*/
typedef id<SentrySpan> _Nullable (^SentryBeforeSendSpanCallback)(id<SentrySpan> _Nonnull span);

#if !SWIFT_PACKAGE
/**
* Use this block to drop or modify a log before the SDK sends it to Sentry. Return @c nil to drop
* the log.
*/
typedef SentryLog *_Nullable (^SentryBeforeSendLogCallback)(SentryLog *_Nonnull log);
#endif // !SWIFT_PACKAGE

/**
* Block can be used to decide if the SDK should capture a screenshot or not. Return @c true if the
* SDK should capture a screenshot, return @c false if not. This callback doesn't work for crashes.
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/Public/SentryDsn.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ NS_ASSUME_NONNULL_BEGIN

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

- (_Nullable instancetype)initWithString:(NSString *)dsnString
- (_Nullable instancetype)initWithString:(NSString *_Nullable)dsnString
didFailWithError:(NSError *_Nullable *_Nullable)error;

- (NSURL *)getEnvelopeEndpoint;
Expand Down
Loading
Loading