You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/product/explore/profiling/transaction-vs-continuous-profiling.mdx
+18-6Lines changed: 18 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,6 @@ description: "Learn about the differences between continuous and transaction-bas
6
6
7
7
We've released a new profiling mode called **continuous profiling**. Read on to learn about the differences between transaction-based and continuous profiling mode.
8
8
9
-
10
9
## Historical Context
11
10
12
11
Transaction-based profiling was the first profiling mode supported by Sentry. It made it so that any code executed between `Sentry.startTransaction` and `transaction.finish` could be profiled. In this mode, all profiles were attached to transactions and sent as part of the same envelope.
@@ -27,7 +26,6 @@ In continuous profiling mode, the profiler runs continuously (no pun intended) a
27
26
28
27
Continuous profiling mode is capable of profiling long-running workflows or processes that you want full visibility into, while transaction-based profiling is intended for workflows where you want to limit profiling to only a subset of your application.
29
28
30
-
31
29
## SDK Differences
32
30
33
31
Transaction-based profiling was opaque from the SDK side, with the SDK being in full control of when the profiler would start and stop based on the transactions it generated. In continuous profiling mode, this is no longer true. Developers can now control when the profiler is started or stopped via new top-level SDK methods. The exact method-naming varies, but most SDKs that support continuous profiling now expose a top level `Sentry.profiler` that exposes a `startProfiling` and `stopProfiling` method. (Please see the SDK docs for exact definitions.)
@@ -36,7 +34,7 @@ We recommend that you call the `startProfiling` method right after the Sentry SD
36
34
37
35
## Choosing Between Transaction and Continuous Profiling Mode
38
36
39
-
Unfortunately, at this time it's not possible to use both profiling modes at the same time since they're mutually exclusive. Since the mode you intend to use is dependent on the SDK initialization arguments, profiling mode will have to be selected when the Sentry SDK is first initialized.
37
+
Currently, it's not possible to use both profiling modes at the same time because they're mutually exclusive. You'll have to choose the SDK initialization arguments for the mode that works best for you when you first initialize the Sentry SDK.
40
38
41
39
To enable continuous profiling, you have to make sure that neither `profileSampleRate` nor `profilesSampler` are set as the values of the `Sentry.Init` call. If either of those values are set, the SDK will default to transaction-based profiling. When the SDK is configured for continuous profiling, the top level calls to start profiles will enable calls to the profiler. If the SDK is configured for transaction-based profiling, these calls will void and not trigger the profiler.
42
40
@@ -45,15 +43,19 @@ Here's an example of how to enable continuous profiling in NodeJS:
45
43
```javascript
46
44
Sentry.Init({
47
45
dsn:"___PUBLIC_DSN___",
48
-
integrations: [nodeProfilingIntegration()]
49
-
})
46
+
integrations: [nodeProfilingIntegration()],
47
+
});
50
48
51
49
Sentry.profiler.startProfiling();
50
+
// Code executed after the first call to startProfiling will now be profiled
51
+
52
+
// You can stop profiling at any time by calling stopProfiling.
53
+
// This can help you isolate the code you wish to profile.
54
+
Sentry.profiler.stopProfiling();
52
55
```
53
56
54
57
If you want to keep using transaction-based profiling, then the options are the same. You can set either the `profilesSampleRate` or the `profilesSampler` option on the SDK.
55
58
56
-
57
59
Here's an example of enabling transaction-based profiling in NodeJS:
58
60
59
61
```javascript
@@ -73,3 +75,13 @@ Note, that while the profiling mode can't be changed at runtime, it's fine for d
73
75
## Differences When Using Sentry
74
76
75
77
The major difference between continuous profiling and transaction-based profiling when using Sentry, is that with continuous profiling you'll be able to visualize a flamegraph for your entire application. This means, that you'll be able to take a step back from the previous transaction-based view and look at your application's runtime as a whole, which makes it easier to prioritize the functions that are slowing down your entire application and not just one particular transaction.
78
+
79
+
## Managing Usage
80
+
81
+
The main difference between transaction-based and continuous profiling is when the profiler runs. Transaction-based profiling starts and stops with every transaction, while continuous profiling runs continuously, but can be manually started and stopped.
82
+
83
+
Continuous profiling can give you visibility into parts of your application that you haven't instrumented. This is especially useful if your instrumentation is incomplete. However, it may also capture idle time, resulting in data that's potentially less valuable.
84
+
85
+
If you want to profile a high-throughput server with little or no idle time, continuous profiling can help reduce costs, as the profiler will not upload duplicated profiling data from overlapping transactions.
86
+
87
+
It's important that you understand the tradeoffs between the two modes and choose the one that best fits your use case. If you're unsure, we recommend starting with continuous profiling because you'll get a more complete picture of your application's performance.
0 commit comments