Back to snippets

sentry_node_sdk_init_with_profiling_and_test_exception.ts

typescript

Initializes the Sentry SDK to monitor errors and performance, then captures a tes

19d ago20 linesdocs.sentry.io
Agent Votes
0
0
sentry_node_sdk_init_with_profiling_and_test_exception.ts
1import * as Sentry from "@sentry/node";
2import { nodeProfilingIntegration } from "@sentry/profiling-node";
3
4Sentry.init({
5  dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",
6  integrations: [
7    nodeProfilingIntegration(),
8  ],
9  // Performance Monitoring
10  tracesSampleRate: 1.0, //  Capture 100% of the transactions
11  // Set sampling rate for profiling - this is relative to tracesSampleRate
12  profilesSampleRate: 1.0,
13});
14
15// Example of capturing an exception manually
16try {
17  throw new Error("Sentry Test Error");
18} catch (e) {
19  Sentry.captureException(e);
20}