Skip to content
Draft
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
40 changes: 10 additions & 30 deletions Sentry.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,6 @@
841325C52BF49EC40029228F /* SentryLaunchProfiling+Tests.h in Headers */ = {isa = PBXBuildFile; fileRef = 841325C42BF49EC40029228F /* SentryLaunchProfiling+Tests.h */; };
841325DF2BFED0510029228F /* TestFramesTracker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 841325DE2BFED0510029228F /* TestFramesTracker.swift */; };
84281C432A578E5600EE88F2 /* SentryProfilerState.mm in Sources */ = {isa = PBXBuildFile; fileRef = 84281C422A578E5600EE88F2 /* SentryProfilerState.mm */; };
84281C462A57905700EE88F2 /* SentrySample.h in Headers */ = {isa = PBXBuildFile; fileRef = 84281C442A57905700EE88F2 /* SentrySample.h */; };
84281C472A57905700EE88F2 /* SentrySample.m in Sources */ = {isa = PBXBuildFile; fileRef = 84281C452A57905700EE88F2 /* SentrySample.m */; };
84281C622A579D0700EE88F2 /* SentryProfilerMocksSwiftCompatible.mm in Sources */ = {isa = PBXBuildFile; fileRef = 84281C4D2A579A0C00EE88F2 /* SentryProfilerMocksSwiftCompatible.mm */; };
84281C632A579D0700EE88F2 /* SentryProfilerMocks.mm in Sources */ = {isa = PBXBuildFile; fileRef = 84281C492A57933600EE88F2 /* SentryProfilerMocks.mm */; };
84302A812B5767A50027A629 /* SentryLaunchProfiling.m in Sources */ = {isa = PBXBuildFile; fileRef = 84302A7F2B5767A50027A629 /* SentryLaunchProfiling.m */; };
Expand Down Expand Up @@ -829,6 +827,8 @@
D8FC98AB2CD0DAB30009824C /* BreadcrumbExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8FC98AA2CD0DAAC0009824C /* BreadcrumbExtension.swift */; };
D8FFE50C2703DBB400607131 /* SwizzlingCallTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8FFE50B2703DAAE00607131 /* SwizzlingCallTests.swift */; };
E6D45062898111B8F077E931 /* MdxOptionsParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CE36243D36AC519A2D8FBE1 /* MdxOptionsParserTests.swift */; };
F400C0CD2F368A8B0042712D /* SentryProfilerSampleCreation.m in Sources */ = {isa = PBXBuildFile; fileRef = F400C0CC2F368A8B0042712D /* SentryProfilerSampleCreation.m */; };
F400C0D42F368A980042712D /* SentryProfilerSampleCreation.h in Headers */ = {isa = PBXBuildFile; fileRef = F400C0D32F368A980042712D /* SentryProfilerSampleCreation.h */; };
F40B7BB52F22E00200771198 /* SentryCoreDataSwizzlingHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = F40B7BB42F22E00200771198 /* SentryCoreDataSwizzlingHelper.m */; };
F40B7BBB2F22E05600771198 /* SentryCoreDataSwizzlingHelperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F40B7BBA2F22E05600771198 /* SentryCoreDataSwizzlingHelperTests.swift */; };
F40E42FB2EAAAD4500E53876 /* PrivateSentrySDKOnlyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F40E42FA2EAAAD4500E53876 /* PrivateSentrySDKOnlyTests.swift */; };
Expand Down Expand Up @@ -1584,8 +1584,6 @@
841325C42BF49EC40029228F /* SentryLaunchProfiling+Tests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "SentryLaunchProfiling+Tests.h"; sourceTree = "<group>"; };
841325DE2BFED0510029228F /* TestFramesTracker.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestFramesTracker.swift; sourceTree = "<group>"; };
84281C422A578E5600EE88F2 /* SentryProfilerState.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = SentryProfilerState.mm; sourceTree = "<group>"; };
84281C442A57905700EE88F2 /* SentrySample.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentrySample.h; path = ../include/SentrySample.h; sourceTree = "<group>"; };
84281C452A57905700EE88F2 /* SentrySample.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentrySample.m; sourceTree = "<group>"; };
84281C482A57933600EE88F2 /* SentryProfilerMocks.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SentryProfilerMocks.h; sourceTree = "<group>"; };
84281C492A57933600EE88F2 /* SentryProfilerMocks.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = SentryProfilerMocks.mm; sourceTree = "<group>"; };
84281C4C2A579A0C00EE88F2 /* SentryProfilerMocksSwiftCompatible.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SentryProfilerMocksSwiftCompatible.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1961,6 +1959,8 @@
D8FFE50B2703DAAE00607131 /* SwizzlingCallTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwizzlingCallTests.swift; sourceTree = "<group>"; };
E69CEDDF745ECE10243A13FA /* PropertyExtractorTests.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = PropertyExtractorTests.swift; sourceTree = "<group>"; };
EE83EA4FB6B0262B3324AEEF /* SentryTelemetryProcessorFactoryTests.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = SentryTelemetryProcessorFactoryTests.swift; sourceTree = "<group>"; };
F400C0CC2F368A8B0042712D /* SentryProfilerSampleCreation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryProfilerSampleCreation.m; sourceTree = "<group>"; };
F400C0D32F368A980042712D /* SentryProfilerSampleCreation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryProfilerSampleCreation.h; path = Sources/Sentry/include/SentryProfilerSampleCreation.h; sourceTree = SOURCE_ROOT; };
F40B7BB42F22E00200771198 /* SentryCoreDataSwizzlingHelper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryCoreDataSwizzlingHelper.m; sourceTree = "<group>"; };
F40B7BBA2F22E05600771198 /* SentryCoreDataSwizzlingHelperTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryCoreDataSwizzlingHelperTests.swift; sourceTree = "<group>"; };
F40E42FA2EAAAD4500E53876 /* PrivateSentrySDKOnlyTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrivateSentrySDKOnlyTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2049,28 +2049,8 @@
/* End PBXFileReference section */

/* Begin PBXFileSystemSynchronizedRootGroup section */
62205C872F2CA40D00F66691 /* TelemetryScopeApplier */ = {
isa = PBXFileSystemSynchronizedRootGroup;
exceptions = (
);
explicitFileTypes = {
};
explicitFolders = (
);
path = TelemetryScopeApplier;
sourceTree = "<group>";
};
FA2111C32F22CE8C00DFFABE /* Swift */ = {
isa = PBXFileSystemSynchronizedRootGroup;
exceptions = (
);
explicitFileTypes = {
};
explicitFolders = (
);
path = Swift;
sourceTree = "<group>";
};
62205C872F2CA40D00F66691 /* TelemetryScopeApplier */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); path = TelemetryScopeApplier; sourceTree = "<group>"; };
FA2111C32F22CE8C00DFFABE /* Swift */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); path = Swift; sourceTree = "<group>"; };
/* End PBXFileSystemSynchronizedRootGroup section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -3400,12 +3380,12 @@
848A45182BBF8D33006AAAEC /* SentryContinuousProfiler.mm */,
0354A22A2A134D9C003C3A04 /* SentryProfilerState.h */,
84281C422A578E5600EE88F2 /* SentryProfilerState.mm */,
F400C0D32F368A980042712D /* SentryProfilerSampleCreation.h */,
F400C0CC2F368A8B0042712D /* SentryProfilerSampleCreation.m */,
84281C642A57D36100EE88F2 /* SentryProfilerState+ObjCpp.h */,
84354E0F29BF944900CDBB8B /* SentryProfileTimeseries.h */,
84354E1029BF944900CDBB8B /* SentryProfileTimeseries.m */,
03BCC38D27E2A377003232C7 /* SentryProfilingConditionals.h */,
84281C442A57905700EE88F2 /* SentrySample.h */,
84281C452A57905700EE88F2 /* SentrySample.m */,
03F84D3027DD4191008FE43F /* SentrySamplingProfiler.cpp */,
03F84D1527DD414C008FE43F /* SentrySamplingProfiler.hpp */,
03F84D1427DD414C008FE43F /* SentryStackBounds.hpp */,
Expand Down Expand Up @@ -4242,6 +4222,7 @@
D452FC732DDB553100AFF56F /* SentryWatchdogTerminationBreadcrumbProcessor.h in Headers */,
FA914E9B2ED61AA800C54BDD /* SentryFormatterSwift.h in Headers */,
D456B4382D706BFE007068CB /* SentrySpanDataKey.h in Headers */,
F400C0D42F368A980042712D /* SentryProfilerSampleCreation.h in Headers */,
7B77BE3527EC8445003C9020 /* SentryDiscardReasonMapper.h in Headers */,
7B610D602512390E00B0B5D9 /* SentrySDK+Private.h in Headers */,
62A456E12B03704A003F19A1 /* SentryUIEventTrackerMode.h in Headers */,
Expand All @@ -4268,7 +4249,6 @@
632331F9240506DF008D91D6 /* SentryScope+Private.h in Headers */,
D8603DD8284F894C000E1227 /* SentryBaggage.h in Headers */,
03F84D2127DD414C008FE43F /* SentrySamplingProfiler.hpp in Headers */,
84281C462A57905700EE88F2 /* SentrySample.h in Headers */,
63FE712B20DA4C1100CDBAE8 /* SentryCrashStackCursor.h in Headers */,
7BA61CBF247CEA8100C130A8 /* SentryFormatter.h in Headers */,
D8370B6C273DF20F00F66E2D /* SentryNSURLSessionTaskSearch.h in Headers */,
Expand Down Expand Up @@ -4831,6 +4811,7 @@
7DB3A687238EA75E00A2D442 /* SentryHttpTransport.m in Sources */,
63FE70D520DA4C1000CDBAE8 /* SentryCrashMonitor_NSException.m in Sources */,
7BC63F0A28081288009D9E37 /* SentrySwizzleWrapperHelper.m in Sources */,
F400C0CD2F368A8B0042712D /* SentryProfilerSampleCreation.m in Sources */,
63295AF71EF3C7DB002D4490 /* SentryNSDictionarySanitize.m in Sources */,
7B8ECBFC26498958005FE2EF /* SentryDefaultAppStateManager.m in Sources */,
FA6555162E30182B009917BC /* SentrySDKInternal.m in Sources */,
Expand Down Expand Up @@ -4864,7 +4845,6 @@
63FE717520DA4C1100CDBAE8 /* SentryCrash.m in Sources */,
7BAF3DCE243DCBFE008A5414 /* SentryTransportFactory.m in Sources */,
7D65260E237F649E00113EA2 /* SentryScope.m in Sources */,
84281C472A57905700EE88F2 /* SentrySample.m in Sources */,
62A456E52B0370E0003F19A1 /* SentryUIEventTrackerTransactionMode.m in Sources */,
D43A2A122DD47FCE00114724 /* SentryWeakMap.m in Sources */,
63FE712D20DA4C1100CDBAE8 /* SentryCrashJSONCodecObjC.m in Sources */,
Expand Down
1 change: 0 additions & 1 deletion Sources/Sentry/Profiling/SentryContinuousProfiler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# import "SentryProfilingScreenFramesHelper.h"
# import "SentryProfilingSwiftHelpers.h"
# import "SentrySDK+Private.h"
# import "SentrySample.h"
# include <mutex>

# if SENTRY_HAS_UIKIT
Expand Down
29 changes: 29 additions & 0 deletions Sources/Sentry/Profiling/SentryProfilerSampleCreation.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#import "SentryProfilerSampleCreation.h"
#if SENTRY_TARGET_PROFILING_SUPPORTED
# import "SentryInternalDefines.h"
# import "SentrySwift.h"

SentrySample *
sentry_profilerSampleWithStack(NSArray<NSNumber *> *stack, uint64_t absoluteTimestamp,
NSTimeInterval absoluteNSDateInterval, uint64_t threadID, SentryProfilerMutableState *state)
{
SentrySample *sample = [[SentrySample alloc] init];
sample.absoluteTimestamp = absoluteTimestamp;
sample.absoluteNSDateInterval = absoluteNSDateInterval;
sample.threadID = threadID;

NSString *stackKey = [stack componentsJoinedByString:@"|"];
NSNumber *_Nullable stackIndex = state.stackIndexLookup[stackKey];
if (stackIndex) {
sample.stackIndex = SENTRY_UNWRAP_NULLABLE(NSNumber, stackIndex);
} else {
NSNumber *nextStackIndex = @(state.stacks.count);
sample.stackIndex = nextStackIndex;
state.stackIndexLookup[stackKey] = nextStackIndex;
[state.stacks addObject:stack];
}

return sample;
}

#endif // SENTRY_TARGET_PROFILING_SUPPORTED
1 change: 0 additions & 1 deletion Sources/Sentry/Profiling/SentryProfilerSerialization.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
# import "SentryProfilerState.h"
# import "SentryProfilerTestHelpers.h"
# import "SentrySDK+Private.h"
# import "SentrySample.h"
# import "SentryScope+Private.h"
# import "SentryScope+PrivateSwift.h"
# import "SentrySerialization.h"
Expand Down
19 changes: 3 additions & 16 deletions Sources/Sentry/Profiling/SentryProfilerState.mm
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
# import "SentryFormatter.h"
# import "SentryInternalDefines.h"
# import "SentryProfileTimeseries.h"
# import "SentryProfilerSampleCreation.h"
# import "SentryProfilingSwiftHelpers.h"
# import "SentrySample.h"
# import <mach/mach_types.h>
# import <mach/port.h>
# import <mutex>
Expand Down Expand Up @@ -158,26 +158,13 @@
free(symbols);
# endif // defined(DEBUG)

const auto sample = [[SentrySample alloc] init];
sample.absoluteTimestamp = backtrace.absoluteTimestamp;
sample.absoluteNSDateInterval = sentry_getDate().timeIntervalSince1970;
sample.threadID = backtrace.threadMetadata.threadID;

const auto stackKey = [stack componentsJoinedByString:@"|"];
NSNumber *_Nullable stackIndex = state.stackIndexLookup[stackKey];
if (stackIndex) {
sample.stackIndex = SENTRY_UNWRAP_NULLABLE(NSNumber, stackIndex);
} else {
const auto nextStackIndex = @(state.stacks.count);
sample.stackIndex = nextStackIndex;
state.stackIndexLookup[stackKey] = nextStackIndex;
[state.stacks addObject:stack];
}
const auto sample = sentry_profilerSampleWithStack(stack, backtrace.absoluteTimestamp,
sentry_getDate().timeIntervalSince1970, backtrace.threadMetadata.threadID, state);

# if defined(DEBUG)
if (backtraceFunctionNames.count > 0) {
SENTRY_ASYNC_SAFE_LOG_DEBUG("Recorded backtrace for thread %s at %llu: %s",
threadID.UTF8String, sample.absoluteTimestamp,

Check failure on line 167 in Sources/Sentry/Profiling/SentryProfilerState.mm

View workflow job for this annotation

GitHub Actions / Check compiling Async Safe Logs

property 'absoluteTimestamp' cannot be found in forward class object 'SentrySample'
backtraceFunctionNames.description.UTF8String);
}
# endif // defined(DEBUG)
Expand Down
4 changes: 0 additions & 4 deletions Sources/Sentry/Profiling/SentrySample.m

This file was deleted.

1 change: 0 additions & 1 deletion Sources/Sentry/SentryProfileTimeseries.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# import "SentryEvent+Private.h"
# import "SentryInternalDefines.h"
# import "SentryLogC.h"
# import "SentrySample.h"
# import "SentryTransaction.h"
# if SENTRY_HAS_UIKIT
# import "SentryFormatter.h"
Expand Down
25 changes: 25 additions & 0 deletions Sources/Sentry/include/SentryProfilerSampleCreation.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#import "SentryProfilingConditionals.h"

#if SENTRY_TARGET_PROFILING_SUPPORTED

# import "SentryProfilerState.h"
# import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

/**
* Creates a profiler sample from a stack of frame indices and appends the stack to state if new.
* Used so that SentrySample (Swift) is only referenced from Objective-C, not from Objective-C++.
*/
# if defined(__cplusplus)
extern "C" {
# endif
SentrySample *sentry_profilerSampleWithStack(NSArray<NSNumber *> *stack, uint64_t absoluteTimestamp,
NSTimeInterval absoluteNSDateInterval, uint64_t threadID, SentryProfilerMutableState *state);
# if defined(__cplusplus)
}
# endif

NS_ASSUME_NONNULL_END

#endif // SENTRY_TARGET_PROFILING_SUPPORTED
14 changes: 0 additions & 14 deletions Sources/Sentry/include/SentrySample.h

This file was deleted.

15 changes: 15 additions & 0 deletions Sources/Swift/Profiling/SentrySample.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Foundation

// swiftlint:disable missing_docs

/// A storage class to hold the data associated with a single profiler sample.
@objcMembers
@_spi(Private) public final class SentrySample: NSObject {
public var absoluteTimestamp: UInt64 = 0
public var absoluteNSDateInterval: TimeInterval = 0
public var stackIndex: NSNumber = NSNumber(value: 0)
public var threadID: UInt64 = 0
public var queueAddress: String?
}

// swiftlint:enable missing_docs
Loading