Skip to content

Commit d3e1ff0

Browse files
ref(onboarding): Move dotnet profiling from utils to dotnet folder (#103138)
Contributes to https://linear.app/getsentry/issue/TET-864/introduce-folders-for-onboarding-platforms
1 parent 30e36b8 commit d3e1ff0

File tree

2 files changed

+184
-196
lines changed

2 files changed

+184
-196
lines changed
Lines changed: 184 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,187 @@
1-
import {getDotnetProfilingOnboarding} from 'sentry/utils/gettingStartedDocs/dotnet';
1+
import {Alert} from 'sentry/components/core/alert';
2+
import {ExternalLink} from 'sentry/components/core/link';
3+
import type {
4+
DocsParams,
5+
OnboardingConfig,
6+
} from 'sentry/components/onboarding/gettingStartedDoc/types';
7+
import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/types';
8+
import {t, tct} from 'sentry/locale';
9+
import {getPackageVersion} from 'sentry/utils/gettingStartedDocs/getPackageVersion';
210

311
import {getInstallSnippetCoreCli, getInstallSnippetPackageManager} from './utils';
412

5-
export const profiling = getDotnetProfilingOnboarding({
6-
getInstallSnippetPackageManager,
7-
getInstallSnippetCoreCli,
8-
});
13+
const getInstallProfilingSnippetPackageManager = (params: DocsParams) => `
14+
Install-Package Sentry.Profiling -Version ${getPackageVersion(
15+
params,
16+
'sentry.dotnet.profiling',
17+
'4.3.0'
18+
)}`;
19+
20+
const getInstallProfilingSnippetCoreCli = (params: DocsParams) => `
21+
dotnet add package Sentry.Profiling -v ${getPackageVersion(
22+
params,
23+
'sentry.dotnet.profiling',
24+
'4.3.0'
25+
)}`;
26+
27+
const getProfilingConfigureSnippet = (
28+
params: DocsParams,
29+
platform?: 'windows' | 'apple'
30+
) => `
31+
using Sentry;
32+
33+
SentrySdk.Init(options =>
34+
{
35+
// A Sentry Data Source Name (DSN) is required.
36+
// See https://docs.sentry.io/product/sentry-basics/dsn-explainer/
37+
// You can set it in the SENTRY_DSN environment variable, or you can set it in code here.
38+
options.Dsn = "${params.dsn.public}";${
39+
params.isPerformanceSelected
40+
? `
41+
42+
// Set TracesSampleRate to 1.0 to capture 100%
43+
// of transactions for tracing.
44+
// We recommend adjusting this value in production.
45+
options.TracesSampleRate = 1.0;`
46+
: ''
47+
}${
48+
params.isProfilingSelected
49+
? `
50+
51+
// Sample rate for profiling, applied on top of othe TracesSampleRate,
52+
// e.g. 0.2 means we want to profile 20 % of the captured transactions.
53+
// We recommend adjusting this value in production.
54+
options.ProfilesSampleRate = 1.0;${
55+
platform === 'apple'
56+
? ''
57+
: `
58+
// Requires NuGet package: Sentry.Profiling
59+
// Note: By default, the profiler is initialized asynchronously. This can
60+
// be tuned by passing a desired initialization timeout to the constructor.
61+
options.AddIntegration(new ProfilingIntegration(
62+
// During startup, wait up to 500ms to profile the app startup code.
63+
// This could make launching the app a bit slower so comment it out if you
64+
// prefer profiling to start asynchronously
65+
TimeSpan.FromMilliseconds(500)
66+
));`
67+
}`
68+
: ''
69+
}
70+
});`;
71+
72+
export const profiling: OnboardingConfig = {
73+
introduction: () => (
74+
<Alert type="info" showIcon={false}>
75+
<div>
76+
{t(
77+
'Sentry profiling for .NET is available in Alpha on .NET 6.0+ (tested on .NET 7.0 & .NET 8.0 as well).'
78+
)}
79+
</div>
80+
<div>{t('Profiling is not supported for .NET Framework and .NET on Android.')}</div>
81+
</Alert>
82+
),
83+
install: params => [
84+
{
85+
type: StepType.INSTALL,
86+
content: [
87+
{
88+
type: 'text',
89+
text: tct(
90+
'Make sure the SDK is up to date. The minimum version of the SDK required for profiling is [code:4.3.0].',
91+
{
92+
code: <code />,
93+
}
94+
),
95+
},
96+
{
97+
type: 'code',
98+
tabs: [
99+
{
100+
label: 'Package Manager',
101+
language: 'shell',
102+
code: getInstallSnippetPackageManager(params),
103+
},
104+
{
105+
label: '.NET Core CLI',
106+
language: 'shell',
107+
code: getInstallSnippetCoreCli(params),
108+
},
109+
],
110+
},
111+
{
112+
type: 'text',
113+
text: tct(
114+
'Additionally, for all platforms except iOS/Mac Catalyst, you need to add a dependency on the [sentryProfilingPackage:Sentry.Profiling] NuGet package.',
115+
{
116+
sentryProfilingPackage: <code />,
117+
}
118+
),
119+
},
120+
{
121+
type: 'code',
122+
tabs: [
123+
{
124+
label: 'Package Manager',
125+
language: 'shell',
126+
code: getInstallProfilingSnippetPackageManager(params),
127+
},
128+
{
129+
label: '.NET Core CLI',
130+
language: 'shell',
131+
code: getInstallProfilingSnippetCoreCli(params),
132+
},
133+
],
134+
},
135+
],
136+
},
137+
],
138+
configure: params => [
139+
{
140+
type: StepType.CONFIGURE,
141+
content: [
142+
{
143+
type: 'text',
144+
text: tct('Enable profiling by updating your [code:SentrySdk.Init] call:', {
145+
code: <code />,
146+
}),
147+
},
148+
{
149+
type: 'code',
150+
tabs: [
151+
{
152+
label: 'Windows/Linux/macOS',
153+
language: 'csharp',
154+
code: getProfilingConfigureSnippet(params, 'windows'),
155+
},
156+
{
157+
label: 'iOS/Mac Catalyst',
158+
language: 'csharp',
159+
code: getProfilingConfigureSnippet(params, 'apple'),
160+
},
161+
],
162+
},
163+
{
164+
type: 'text',
165+
text: tct('For more information, read the [link:profiling documentation].', {
166+
link: (
167+
<ExternalLink href="https://docs.sentry.io/platforms/dotnet/profiling/" />
168+
),
169+
}),
170+
},
171+
],
172+
},
173+
],
174+
verify: () => [
175+
{
176+
type: StepType.VERIFY,
177+
content: [
178+
{
179+
type: 'text',
180+
text: t(
181+
'Verify that profiling is working correctly by simply using your application.'
182+
),
183+
},
184+
],
185+
},
186+
],
187+
};

static/app/utils/gettingStartedDocs/dotnet.tsx

Lines changed: 0 additions & 191 deletions
This file was deleted.

0 commit comments

Comments
 (0)