Skip to content

Commit

Permalink
feat: profile concurrent transactions (#2105)
Browse files Browse the repository at this point in the history
* ref: move test cases from SentryHubTests.swift dealing with profiling into new //Tests/SentryTests/Profiling/SentryProfilerTests.swift; remove redundant tests for profiling in tracer tests
* clamp relative start/end transaction times to profile; add more logging
* stop profiler after a 30s timeout
* refactor profiling code to extract from SentryTracer to SentryProfiler and move as much state into ivars as possible
* moved the call to stop the profiler to after another early return in - [SentryTracer finishInternal:]
* moved the call to capture the profiling envelope there until after the early return that drops transactions due to pre-warm durations
  • Loading branch information
armcknight authored Sep 24, 2022
1 parent 4a66f00 commit e43ce74
Show file tree
Hide file tree
Showing 14 changed files with 724 additions and 428 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
- [File I/O Tracking](https://docs.sentry.io/platforms/apple/performance/instrumentation/automatic-instrumentation/#file-io-tracking) is stable (#2212)
- Add flush (#2140)
- Add more device context (#2190)
- Profile concurrent transactions (#2105)

## 7.25.1

### Fixes

Expand Down
8 changes: 8 additions & 0 deletions Sentry.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -581,8 +581,10 @@
7DC83100239826280043DD9A /* SentryIntegrationProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 7DC830FF239826280043DD9A /* SentryIntegrationProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
7DC8310A2398283C0043DD9A /* SentryCrashIntegration.h in Headers */ = {isa = PBXBuildFile; fileRef = 7DC831082398283C0043DD9A /* SentryCrashIntegration.h */; };
7DC8310C2398283C0043DD9A /* SentryCrashIntegration.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DC831092398283C0043DD9A /* SentryCrashIntegration.m */; };
8419C0C428C1889D001C8259 /* SentryProfilerSwiftTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8419C0C328C1889D001C8259 /* SentryProfilerSwiftTests.swift */; };
8453421228BE855D00C22EEC /* SentrySampleDecision.m in Sources */ = {isa = PBXBuildFile; fileRef = 8453421128BE855D00C22EEC /* SentrySampleDecision.m */; };
8453421628BE8A9500C22EEC /* SentrySpanStatus.m in Sources */ = {isa = PBXBuildFile; fileRef = 8453421528BE8A9500C22EEC /* SentrySpanStatus.m */; };
84A888FD28D9B11700C51DFD /* SentryProfiler+Test.h in Headers */ = {isa = PBXBuildFile; fileRef = 84A888FC28D9B11700C51DFD /* SentryProfiler+Test.h */; };
861265F92404EC1500C4AFDE /* NSArray+SentrySanitize.h in Headers */ = {isa = PBXBuildFile; fileRef = 861265F72404EC1500C4AFDE /* NSArray+SentrySanitize.h */; };
861265FA2404EC1500C4AFDE /* NSArray+SentrySanitize.m in Sources */ = {isa = PBXBuildFile; fileRef = 861265F82404EC1500C4AFDE /* NSArray+SentrySanitize.m */; };
8E0551E026A7A63C00400526 /* TestProtocolClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8E0551DF26A7A63C00400526 /* TestProtocolClient.swift */; };
Expand Down Expand Up @@ -1323,6 +1325,7 @@
7DC830FF239826280043DD9A /* SentryIntegrationProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryIntegrationProtocol.h; path = Public/SentryIntegrationProtocol.h; sourceTree = "<group>"; };
7DC831082398283C0043DD9A /* SentryCrashIntegration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryCrashIntegration.h; path = include/SentryCrashIntegration.h; sourceTree = "<group>"; };
7DC831092398283C0043DD9A /* SentryCrashIntegration.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryCrashIntegration.m; sourceTree = "<group>"; };
8419C0C328C1889D001C8259 /* SentryProfilerSwiftTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryProfilerSwiftTests.swift; sourceTree = "<group>"; };
844A34C3282B278500C6D1DF /* .github */ = {isa = PBXFileReference; lastKnownFileType = folder; path = .github; sourceTree = "<group>"; };
844A3563282B3C9F00C6D1DF /* .sauce */ = {isa = PBXFileReference; lastKnownFileType = folder; path = .sauce; sourceTree = "<group>"; };
844DA7F6282435CD00E6B62E /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
Expand All @@ -1348,6 +1351,7 @@
844DA81F28246DE300E6B62E /* scripts */ = {isa = PBXFileReference; lastKnownFileType = folder; path = scripts; sourceTree = "<group>"; };
8453421128BE855D00C22EEC /* SentrySampleDecision.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentrySampleDecision.m; sourceTree = "<group>"; };
8453421528BE8A9500C22EEC /* SentrySpanStatus.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentrySpanStatus.m; sourceTree = "<group>"; };
84A888FC28D9B11700C51DFD /* SentryProfiler+Test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "SentryProfiler+Test.h"; path = "Sources/Sentry/include/SentryProfiler+Test.h"; sourceTree = SOURCE_ROOT; };
861265F72404EC1500C4AFDE /* NSArray+SentrySanitize.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "NSArray+SentrySanitize.h"; path = "include/NSArray+SentrySanitize.h"; sourceTree = "<group>"; };
861265F82404EC1500C4AFDE /* NSArray+SentrySanitize.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSArray+SentrySanitize.m"; sourceTree = "<group>"; };
8E0551DF26A7A63C00400526 /* TestProtocolClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestProtocolClient.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1497,6 +1501,7 @@
035E73CB27D575B3005EEB11 /* SentrySamplingProfilerTests.mm */,
035E73CD27D5790A005EEB11 /* SentryThreadMetadataCacheTests.mm */,
03F9D37B2819A65C00602916 /* SentryProfilerTests.mm */,
8419C0C328C1889D001C8259 /* SentryProfilerSwiftTests.swift */,
);
path = Profiling;
sourceTree = "<group>";
Expand Down Expand Up @@ -2678,6 +2683,7 @@
03F84D1B27DD414C008FE43F /* SentryMachLogging.hpp */,
03F84D2C27DD4191008FE43F /* SentryMachLogging.cpp */,
03F84D1127DD414C008FE43F /* SentryProfiler.h */,
84A888FC28D9B11700C51DFD /* SentryProfiler+Test.h */,
03F84D2B27DD4191008FE43F /* SentryProfiler.mm */,
03BCC38D27E2A377003232C7 /* SentryProfilingConditionals.h */,
03F84D2927DD416B008FE43F /* SentryProfilingLogging.hpp */,
Expand Down Expand Up @@ -2923,6 +2929,7 @@
8EE3251C261FE33B00DC3FF2 /* SentryUIViewControllerSanitizer.h in Headers */,
7BAF3DD92440AEC8008A5414 /* SentryRequestManager.h in Headers */,
7BE3C77B2446111500A38442 /* SentryRateLimitParser.h in Headers */,
84A888FD28D9B11700C51DFD /* SentryProfiler+Test.h in Headers */,
7D0637032382B34300B30749 /* SentryScope.h in Headers */,
03F84D2727DD414C008FE43F /* SentryMachLogging.hpp in Headers */,
0356A570288B4612008BF593 /* SentryProfilesSampler.h in Headers */,
Expand Down Expand Up @@ -3505,6 +3512,7 @@
63FE720520DA66EC00CDBAE8 /* FileBasedTestCase.m in Sources */,
0A6EEADD28A657970076B469 /* UIViewRecursiveDescriptionTests.swift in Sources */,
63EED6C32237989300E02400 /* SentryOptionsTest.m in Sources */,
8419C0C428C1889D001C8259 /* SentryProfilerSwiftTests.swift in Sources */,
7BBD18B22451804C00427C76 /* SentryRetryAfterHeaderParserTests.swift in Sources */,
7BD337E424A356180050DB6E /* SentryCrashIntegrationTests.swift in Sources */,
7BD4E8E827FD95900086C410 /* SentryMigrateSessionInitTests.m in Sources */,
Expand Down
5 changes: 3 additions & 2 deletions Sources/Sentry/SentryFramesTracker.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#import "SentryFramesTracker.h"
#import "SentryDisplayLinkWrapper.h"
#import "SentryProfiler.h"
#import "SentryProfilingConditionals.h"
#import "SentryTracer.h"
#import <SentryScreenFrames.h>
Expand Down Expand Up @@ -123,7 +124,7 @@ - (void)displayLinkCallback
}

# if SENTRY_TARGET_PROFILING_SUPPORTED
if (self.currentTracer.isProfiling
if ([SentryProfiler isRunning]
&& (self.frameRateTimestamps.count == 0
|| self.frameRateTimestamps.lastObject[@"frame_rate"].doubleValue
!= actualFramesPerSecond)) {
Expand Down Expand Up @@ -161,7 +162,7 @@ - (void)displayLinkCallback
# if SENTRY_TARGET_PROFILING_SUPPORTED
- (void)recordTimestampStart:(NSNumber *)start end:(NSNumber *)end
{
if (self.currentTracer.isProfiling) {
if ([SentryProfiler isRunning]) {
[self.frameTimestamps addObject:@{ @"start_timestamp" : start, @"end_timestamp" : end }];
}
}
Expand Down
Loading

0 comments on commit e43ce74

Please sign in to comment.