|
1 |
| -import type {DocsParams} from 'sentry/components/onboarding/gettingStartedDoc/types'; |
| 1 | +import ExternalLink from 'sentry/components/links/externalLink'; |
| 2 | +import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step'; |
| 3 | +import type { |
| 4 | + DocsParams, |
| 5 | + OnboardingConfig, |
| 6 | +} from 'sentry/components/onboarding/gettingStartedDoc/types'; |
| 7 | +import {t, tct} from 'sentry/locale'; |
2 | 8 |
|
3 | 9 | export function getInstallSnippet({
|
4 | 10 | params,
|
@@ -205,3 +211,108 @@ Sentry.startSpan({
|
205 | 211 | });`
|
206 | 212 | : ''
|
207 | 213 | }`;
|
| 214 | + |
| 215 | +export const getNodeProfilingOnboarding = ({ |
| 216 | + basePackage = '@sentry/node', |
| 217 | +}: { |
| 218 | + basePackage?: string; |
| 219 | +} = {}): OnboardingConfig => ({ |
| 220 | + install: params => [ |
| 221 | + { |
| 222 | + type: StepType.INSTALL, |
| 223 | + description: tct( |
| 224 | + 'To enable profiling, add [code:@sentry/profiling-node] to your imports.', |
| 225 | + { |
| 226 | + code: <code />, |
| 227 | + } |
| 228 | + ), |
| 229 | + configurations: getInstallConfig(params, { |
| 230 | + basePackage, |
| 231 | + }), |
| 232 | + }, |
| 233 | + ], |
| 234 | + configure: params => [ |
| 235 | + { |
| 236 | + type: StepType.CONFIGURE, |
| 237 | + description: tct( |
| 238 | + 'Set up the [code:nodeProfilingIntegration] in your [code:Sentry.init()] call.', |
| 239 | + { |
| 240 | + code: <code />, |
| 241 | + } |
| 242 | + ), |
| 243 | + configurations: [ |
| 244 | + { |
| 245 | + language: 'javascript', |
| 246 | + code: [ |
| 247 | + { |
| 248 | + label: 'Javascript', |
| 249 | + value: 'javascript', |
| 250 | + language: 'javascript', |
| 251 | + code: ` |
| 252 | +Sentry.init({ |
| 253 | + dsn: "${params.dsn.public}", |
| 254 | + integrations: [ |
| 255 | + nodeProfilingIntegration(), |
| 256 | + ], |
| 257 | + // Tracing must be enabled for profiling to work |
| 258 | + tracesSampleRate: 1.0, // Capture 100% of the transactions${ |
| 259 | + params.profilingOptions?.defaultProfilingMode === 'continuous' |
| 260 | + ? ` |
| 261 | + // Set sampling rate for profiling - this is evaluated only once per SDK.init call |
| 262 | + profileSessionSampleRate: 1.0, |
| 263 | + // Trace lifecycle automatically enables profiling during active traces |
| 264 | + profileLifecycle: 'trace',` |
| 265 | + : ` |
| 266 | + // Set sampling rate for profiling - this is evaluated only once per SDK.init call |
| 267 | + profilesSampleRate: 1.0,` |
| 268 | + } |
| 269 | +});${ |
| 270 | + params.profilingOptions?.defaultProfilingMode === 'continuous' |
| 271 | + ? ` |
| 272 | +
|
| 273 | +// Profiling happens automatically after setting it up with \`Sentry.init()\`. |
| 274 | +// All spans (unless those discarded by sampling) will have profiling data attached to them. |
| 275 | +Sentry.startSpan({ |
| 276 | + name: "My Span", |
| 277 | +}, () => { |
| 278 | + // The code executed here will be profiled |
| 279 | +});` |
| 280 | + : '' |
| 281 | + }`, |
| 282 | + }, |
| 283 | + ], |
| 284 | + additionalInfo: tct( |
| 285 | + 'If you need more fine grained control over which spans are profiled, you can do so by [link:enabling manual lifecycle profiling].', |
| 286 | + { |
| 287 | + link: ( |
| 288 | + <ExternalLink |
| 289 | + href={`https://docs.sentry.io/platforms/javascript/guides/node/profiling/node-profiling/#enabling-manual-lifecycle-profiling`} |
| 290 | + /> |
| 291 | + ), |
| 292 | + } |
| 293 | + ), |
| 294 | + }, |
| 295 | + { |
| 296 | + description: tct( |
| 297 | + 'For more detailed information on profiling, see the [link:profiling documentation].', |
| 298 | + { |
| 299 | + link: ( |
| 300 | + <ExternalLink |
| 301 | + href={`https://docs.sentry.io/platforms/javascript/guides/node/profiling/node-profiling/`} |
| 302 | + /> |
| 303 | + ), |
| 304 | + } |
| 305 | + ), |
| 306 | + }, |
| 307 | + ], |
| 308 | + }, |
| 309 | + ], |
| 310 | + verify: () => [ |
| 311 | + { |
| 312 | + type: StepType.VERIFY, |
| 313 | + description: t( |
| 314 | + 'Verify that profiling is working correctly by simply using your application.' |
| 315 | + ), |
| 316 | + }, |
| 317 | + ], |
| 318 | +}); |
0 commit comments