Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(launch profiling): use dedicated traces instead of auto perf traces #3621

Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
063bf35
test: integration test for app launch profiling
armcknight Jan 13, 2024
46341fd
fix integration tests after moving to a launch profiling marker file
armcknight Jan 20, 2024
3893093
pr feedback: test new option's default value
armcknight Jan 19, 2024
ceddcd9
comment conditional complier closures
armcknight Jan 22, 2024
7d8b5f7
add unit tests for setting the option and option configurations
armcknight Jan 23, 2024
98155c5
fix tests after reimplementing writing the sample rates to the file
armcknight Jan 25, 2024
d24345a
Merge branch 'armcknight/feat/launch-profiling' into armcknight/test/…
armcknight Jan 30, 2024
39efa27
pr feedback: rename new var
armcknight Jan 30, 2024
ca7127c
pr feedback: iOS availability
armcknight Jan 30, 2024
435a9eb
pr feedback: don't include the test interface extension
armcknight Jan 30, 2024
0422c94
fix macos build
armcknight Jan 30, 2024
231d816
pr feedback: move declaration from SentryFileManager test ext
armcknight Jan 30, 2024
17d006e
don't set isTracingAppLaunch to NO until after doing the work to pack…
armcknight Jan 31, 2024
4ef847b
only check for enableSwizzling in UIKit builds
armcknight Jan 31, 2024
f715546
test: manage files in sample app from integration test
armcknight Feb 2, 2024
9c143a7
test: integration test fixes and additions
armcknight Feb 2, 2024
7bc6c28
logging
armcknight Feb 2, 2024
8b854ec
feat(app launch profiling): save sample rates config to backup
armcknight Feb 2, 2024
251338a
Merge branch 'armcknight/feat/launch-profiling' into armcknight/test/…
armcknight Feb 2, 2024
6c9c344
Merge branch 'armcknight/test/launch-profiling' into armcknight/test/…
armcknight Feb 2, 2024
66905ed
Merge branch 'armcknight/test/launch-profiling2' into armcknight/test…
armcknight Feb 2, 2024
c544ea7
Merge branch 'armcknight/test/launch-profiling3' into armcknight/feat…
armcknight Feb 2, 2024
3574494
pr feedback: tests, edge cases and refactor/reuse file removal logic
armcknight Feb 6, 2024
15f4b7b
wip: need to thread the stored sample rate to isTracingEnabled or whe…
armcknight Feb 5, 2024
2fd98c0
pr feedback: rename
armcknight Feb 6, 2024
522379d
Merge branch 'armcknight/feat/launch-profiling' into armcknight/test/…
armcknight Feb 7, 2024
e4ae98b
Merge branch 'armcknight/test/launch-profiling' into armcknight/test/…
armcknight Feb 7, 2024
155ca7f
Merge branch 'armcknight/test/launch-profiling2' into armcknight/test…
armcknight Feb 7, 2024
5beb31c
Merge branch 'armcknight/test/launch-profiling3' into armcknight/feat…
armcknight Feb 7, 2024
3af711b
fix test on macos (isnt applicable)
armcknight Feb 7, 2024
b799c57
add availability declaration to fix some ui tests that are failing to…
armcknight Feb 7, 2024
af92442
Merge branch 'armcknight/feat/launch-profiling' into armcknight/test/…
armcknight Feb 7, 2024
2fe9785
Merge branch 'armcknight/test/launch-profiling' into armcknight/test/…
armcknight Feb 7, 2024
b08b5fc
Merge branch 'armcknight/test/launch-profiling2' into armcknight/test…
armcknight Feb 7, 2024
4e1b039
Merge branch 'armcknight/test/launch-profiling3' into armcknight/feat…
armcknight Feb 7, 2024
b79b303
wip
armcknight Feb 7, 2024
854d063
wip moving to starting a trace for the launch profile instead storing…
armcknight Feb 8, 2024
f249844
put back hub the way it was
armcknight Feb 8, 2024
6cd924a
remove the need for a backup config file
armcknight Feb 8, 2024
266d060
remainder of conversion to creating dedicated launch traces
armcknight Feb 8, 2024
26f62c3
Merge branch 'armcknight/feat/launch-profiling2' into armcknight/feat…
armcknight Feb 8, 2024
21ac5d3
Merge branch 'armcknight/feat/launch-profiling' into armcknight/test/…
armcknight Feb 8, 2024
bf12020
Merge branch 'armcknight/feat/launch-profiling' into armcknight/test/…
armcknight Feb 8, 2024
97de0c4
Merge branch 'armcknight/test/launch-profiling' into armcknight/test/…
armcknight Feb 8, 2024
a931f3a
Merge branch 'armcknight/test/launch-profiling2' into armcknight/test…
armcknight Feb 8, 2024
af86ee9
Merge branch 'armcknight/test/launch-profiling3' into armcknight/feat…
armcknight Feb 8, 2024
1717ae1
Merge branch 'armcknight/feat/launch-profiling2' into armcknight/feat…
armcknight Feb 8, 2024
a69b25e
wip: debug why SlowLoad frames don't appear in flamegraphs
armcknight Feb 8, 2024
cc31af8
Merge branch 'armcknight/feat/launch-profiling' into armcknight/feat/…
armcknight Feb 8, 2024
715eaf7
fix merge conflict resolutions
armcknight Feb 12, 2024
9ff69f0
remove requirements on auto perf, swizzling and uivc tracking
armcknight Feb 15, 2024
e28778c
update unit tests
armcknight Feb 15, 2024
e642a91
remove nullable annotation
armcknight Feb 15, 2024
f45a7f7
fix(launch profiling): fix data wipe between integration test runs (#…
armcknight Feb 15, 2024
807ac47
fix changelog
armcknight Feb 15, 2024
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
6 changes: 6 additions & 0 deletions Samples/iOS-Swift/iOS-Swift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
84B527BD28DD25E400475E8D /* SentryDevice.mm in Sources */ = {isa = PBXBuildFile; fileRef = 84B527BC28DD25E400475E8D /* SentryDevice.mm */; };
84BE546F287503F100ACC735 /* SentrySDKPerformanceBenchmarkTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 84BE546E287503F100ACC735 /* SentrySDKPerformanceBenchmarkTests.m */; };
84BE547E287645B900ACC735 /* SentryProcessInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 84BE54792876451D00ACC735 /* SentryProcessInfo.m */; };
84DEE88E2B6A4D1200A7BC17 /* AppStartup.m in Sources */ = {isa = PBXBuildFile; fileRef = 84DEE88D2B6A4D1200A7BC17 /* AppStartup.m */; };
84FB812A284001B800F3A94A /* SentryBenchmarking.mm in Sources */ = {isa = PBXBuildFile; fileRef = 84FB8129284001B800F3A94A /* SentryBenchmarking.mm */; };
84FB812B284001B800F3A94A /* SentryBenchmarking.mm in Sources */ = {isa = PBXBuildFile; fileRef = 84FB8129284001B800F3A94A /* SentryBenchmarking.mm */; };
8E8C57AF25EF16E6001CEEFA /* TraceTestViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8E8C57AE25EF16E6001CEEFA /* TraceTestViewController.swift */; };
Expand Down Expand Up @@ -314,6 +315,8 @@
84BE546E287503F100ACC735 /* SentrySDKPerformanceBenchmarkTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentrySDKPerformanceBenchmarkTests.m; sourceTree = "<group>"; };
84BE54782876451D00ACC735 /* SentryProcessInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SentryProcessInfo.h; sourceTree = "<group>"; };
84BE54792876451D00ACC735 /* SentryProcessInfo.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryProcessInfo.m; sourceTree = "<group>"; };
84DEE88C2B6A4D1200A7BC17 /* AppStartup.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppStartup.h; sourceTree = "<group>"; };
84DEE88D2B6A4D1200A7BC17 /* AppStartup.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppStartup.m; sourceTree = "<group>"; };
84FB8125284001B800F3A94A /* SentryBenchmarking.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SentryBenchmarking.h; sourceTree = "<group>"; };
84FB8129284001B800F3A94A /* SentryBenchmarking.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = SentryBenchmarking.mm; sourceTree = "<group>"; };
84FB812C2840021B00F3A94A /* iOS-Swift-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "iOS-Swift-Bridging-Header.h"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -475,6 +478,8 @@
D8DBDA73274D4DF900007380 /* ViewControllers */,
63F93AA9245AC91600A500DB /* iOS-Swift.entitlements */,
637AFDA9243B02760034958B /* AppDelegate.swift */,
84DEE88C2B6A4D1200A7BC17 /* AppStartup.h */,
84DEE88D2B6A4D1200A7BC17 /* AppStartup.m */,
637AFDAD243B02760034958B /* TransactionsViewController.swift */,
84AB90782A50031B0054C99A /* Profiling */,
D80D021229EE93630084393D /* ErrorsViewController.swift */,
Expand Down Expand Up @@ -953,6 +958,7 @@
7B79000429028C7300A7F467 /* MetricKitManager.swift in Sources */,
D8D7BB4A2750067900044146 /* UIAssert.swift in Sources */,
D8F3D057274E574200B56F8C /* LoremIpsumViewController.swift in Sources */,
84DEE88E2B6A4D1200A7BC17 /* AppStartup.m in Sources */,
629EC8AD2B0B537400858855 /* ANRs.swift in Sources */,
D8DBDA78274D5FC400007380 /* SplitViewController.swift in Sources */,
84ACC43C2A73CB5900932A18 /* ProfilingNetworkScanner.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
buildConfiguration = "Test"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
Expand Down Expand Up @@ -73,6 +73,18 @@
argument = "--disable-file-io-tracing"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "--disable-watchdog-tracking"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "--disable-tracing"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "--io.sentry.test.profilesAppLaunches"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "--disable-crash-handler"
isEnabled = "NO">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
buildConfiguration = "Test"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
Expand Down
26 changes: 7 additions & 19 deletions Samples/iOS-Swift/iOS-Swift/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}
options.tracesSampleRate = tracesSampleRate

if let tracesSamplerValue = env["--io.sentry.tracersSamplerValue"] {
if let tracesSamplerValue = env["--io.sentry.tracesSamplerValue"] {
options.tracesSampler = { _ in
return NSNumber(value: (tracesSamplerValue as NSString).integerValue)
}
Expand All @@ -51,7 +51,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
return NSNumber(value: (profilesSamplerValue as NSString).integerValue)
}
}


options.enableAppLaunchProfiling = args.contains("--profile-app-launches")

options.sessionTrackingIntervalMillis = 5_000
options.attachScreenshot = true
options.attachViewHierarchy = true
Expand Down Expand Up @@ -81,9 +83,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
options.enableNetworkBreadcrumbs = !args.contains("--disable-network-breadcrumbs")
options.enableSwizzling = !args.contains("--disable-swizzling")
options.enableCrashHandler = !args.contains("--disable-crash-handler")
options.enableTracing = !args.contains("--disable-tracing")

// because we run CPU for 15 seconds at full throttle, we trigger ANR issues being sent. disable such during benchmarks.
options.enableAppHangTracking = !isBenchmarking && !args.contains("--disable-anr-tracking")
options.enableWatchdogTerminationTracking = !isBenchmarking && !args.contains("--disable-watchdog-tracking")
options.appHangTimeoutInterval = 2
options.enableCaptureFailedRequests = true
let httpStatusCodeRange = HttpStatusCodeRange(min: 400, max: 599)
Expand All @@ -96,7 +100,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}

options.initialScope = { scope in
let processInfoEnvironment = ProcessInfo.processInfo.environment["io.sentry.sdk-environment"]
let processInfoEnvironment = env["io.sentry.sdk-environment"]

if processInfoEnvironment != nil {
scope.setEnvironment(processInfoEnvironment)
Expand Down Expand Up @@ -129,7 +133,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
print("[iOS-Swift] launch arguments: \(ProcessInfo.processInfo.arguments)")
print("[iOS-Swift] environment: \(ProcessInfo.processInfo.environment)")

maybeWipeData()
AppDelegate.startSentry()

if #available(iOS 15.0, *) {
Expand Down Expand Up @@ -159,18 +162,3 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// swiftlint:enable force_cast
}
}

private extension AppDelegate {
func maybeWipeData() {
if ProcessInfo.processInfo.arguments.contains("--io.sentry.wipe-data") {
print("[iOS-Swift] removing app data")
let appSupport = NSSearchPathForDirectoriesInDomains(.applicationSupportDirectory, .userDomainMask, true).first!
let cache = NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true).first!
for path in [appSupport, cache] {
for item in FileManager.default.enumerator(atPath: path)! {
try! FileManager.default.removeItem(atPath: (path as NSString).appendingPathComponent((item as! String)))
}
}
}
}
}
17 changes: 17 additions & 0 deletions Samples/iOS-Swift/iOS-Swift/AppStartup.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// AppStartup.h
// iOS-Swift
//
// Created by Andrew McKnight on 1/31/24.
// Copyright © 2024 Sentry. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface AppStartup : NSObject

@end

NS_ASSUME_NONNULL_END
26 changes: 26 additions & 0 deletions Samples/iOS-Swift/iOS-Swift/AppStartup.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#import "AppStartup.h"

@implementation AppStartup

// we must do this in objective c, because it's not permitted to be overridden in Swift
+ (void)load
{
if ([NSProcessInfo.processInfo.arguments containsObject:@"--io.sentry.wipe-data"]) {
NSLog(@"[iOS-Swift] removing app data");
NSString *appSupport = [NSSearchPathForDirectoriesInDomains(
NSApplicationSupportDirectory, NSUserDomainMask, true) firstObject];
NSString *cache = [NSSearchPathForDirectoriesInDomains(
NSCachesDirectory, NSUserDomainMask, true) firstObject];
NSFileManager *fm = NSFileManager.defaultManager;
for (NSString *dir in @[ appSupport, cache ]) {
for (NSString *file in [fm enumeratorAtPath:dir]) {
NSError *error;
if (![fm removeItemAtPath:[dir stringByAppendingPathComponent:file] error:&error]) {
NSLog(@"[iOS-Swift] failed to remove data at app startup.");
}
}
}
}
}

@end
Loading
Loading