Skip to content

Commit a99f496

Browse files
armcknightZylphrexArthurKnaus
authored andcommitted
feat: convert onboarding to continuous profiling v2 (#88507)
Convert the onboarding instructions for cocoa onboarding profiling options for the new V2 API. For getsentry/sentry-cocoa#4996 --------- Co-authored-by: Tony Xiao <txiao@sentry.io> Co-authored-by: Arthur Knaus <arthur.knaus@sentry.io>
1 parent 031b903 commit a99f496

File tree

2 files changed

+30
-38
lines changed

2 files changed

+30
-38
lines changed

static/app/gettingStartedDocs/apple/ios.spec.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,16 @@ describe('apple-ios onboarding docs', function () {
7575
).not.toBeInTheDocument();
7676

7777
// Does render continuous profiling config
78-
const startMatches = screen.queryAllByText(
79-
textWithMarkupMatcher(/SentrySDK.startProfiler\(\)/)
78+
const sessionSampleRateElements = screen.queryAllByText(
79+
textWithMarkupMatcher(/\$0\.sessionSampleRate = 1\.0/)
8080
);
81-
expect(startMatches.length).toBeGreaterThan(0);
82-
startMatches.forEach(match => expect(match).toBeInTheDocument());
81+
expect(sessionSampleRateElements).toHaveLength(2);
82+
sessionSampleRateElements.forEach(element => expect(element).toBeInTheDocument());
8383

84-
const stopMatches = screen.queryAllByText(
85-
textWithMarkupMatcher(/SentrySDK.stopProfiler\(\)/)
84+
const lifecycleElements = screen.queryAllByText(
85+
textWithMarkupMatcher(/\$0\.lifecycle = \.trace/)
8686
);
87-
expect(stopMatches.length).toBeGreaterThan(0);
88-
stopMatches.forEach(match => expect(match).toBeInTheDocument());
87+
expect(lifecycleElements).toHaveLength(2);
88+
lifecycleElements.forEach(element => expect(element).toBeInTheDocument());
8989
});
9090
});

static/app/gettingStartedDocs/apple/ios.tsx

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -82,22 +82,18 @@ func application(_ application: UIApplication,
8282
// Sample rate for profiling, applied on top of TracesSampleRate.
8383
// We recommend adjusting this value in production.
8484
options.profilesSampleRate = 1.0`
85-
: ''
86-
}
87-
}${
88-
params.isProfilingSelected &&
89-
params.profilingOptions?.defaultProfilingMode === 'continuous'
90-
? `
85+
: params.isProfilingSelected &&
86+
params.profilingOptions?.defaultProfilingMode === 'continuous'
87+
? `
9188
92-
// Manually call startProfiler and stopProfiler
93-
// to profile the code in between
94-
SentrySDK.startProfiler()
95-
// this code will be profiled
96-
//
97-
// Calls to stopProfiler are optional - if you don't stop the profiler, it will keep profiling
98-
// your application until the process exits or stopProfiler is called.
99-
SentrySDK.stopProfiler()`
100-
: ''
89+
// Configure the profiler to start profiling when there is an active root span
90+
// For more information, visit: https://docs.sentry.io/platforms/apple/profiling/
91+
options.configureProfiling = {
92+
$0.lifecycle = .trace
93+
$0.sessionSampleRate = 1.0
94+
}`
95+
: ''
96+
}
10197
}
10298
10399
return true
@@ -131,22 +127,18 @@ struct SwiftUIApp: App {
131127
// Sample rate for profiling, applied on top of TracesSampleRate.
132128
// We recommend adjusting this value in production.
133129
options.profilesSampleRate = 1.0`
134-
: ''
135-
}
136-
}${
137-
params.isProfilingSelected &&
138-
params.profilingOptions?.defaultProfilingMode === 'continuous'
139-
? `
130+
: params.isProfilingSelected &&
131+
params.profilingOptions?.defaultProfilingMode === 'continuous'
132+
? `
140133
141-
// Manually call startProfiler and stopProfiler
142-
// to profile the code in between
143-
SentrySDK.startProfiler()
144-
// this code will be profiled
145-
//
146-
// Calls to stopProfiler are optional - if you don't stop the profiler, it will keep profiling
147-
// your application until the process exits or stopProfiler is called.
148-
SentrySDK.stopProfiler()`
149-
: ''
134+
// Configure the profiler to start profiling when there is an active root span
135+
// For more information, visit: https://docs.sentry.io/platforms/apple/profiling/
136+
options.configureProfiling = {
137+
$0.lifecycle = .trace
138+
$0.sessionSampleRate = 1.0
139+
}`
140+
: ''
141+
}
150142
}
151143
}
152144
}`;

0 commit comments

Comments
 (0)