-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs(profiling): add new cont profiling page docs #11376
Open
JonasBa
wants to merge
11
commits into
master
Choose a base branch
from
jb/profiling/cont-profiling
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
0532593
docs(profiling): add new cont profiling page docs
JonasBa aa18b43
ref(profiling) add doc page explaining the two modes
JonasBa 89acac7
ref(docs) fix title caps
JonasBa c06da60
ref(profiling) add profiling doc section
JonasBa 4f50514
Update docs/product/explore/profiling/transaction-vs-continuous-profi…
JonasBa 3c0ab0e
Update docs/product/explore/profiling/transaction-vs-continuous-profi…
JonasBa 94c63ec
Update docs/product/explore/profiling/transaction-vs-continuous-profi…
JonasBa 3439040
Update docs/product/explore/profiling/transaction-vs-continuous-profi…
JonasBa bc6ebfb
Update docs/product/explore/profiling/transaction-vs-continuous-profi…
JonasBa 0a5194c
Update docs/product/explore/profiling/transaction-vs-continuous-profi…
JonasBa 773ce17
Update docs/product/explore/profiling/transaction-vs-continuous-profi…
JonasBa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
docs/product/explore/profiling/transaction-vs-continuous-profiling.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,77 @@ | ||||||||||||||||||||||||||
--- | ||||||||||||||||||||||||||
title: Transaction vs Continuous Profiling | ||||||||||||||||||||||||||
sidebar_order: 140 | ||||||||||||||||||||||||||
description: "Learn about the differences between continuous and transaction-based profiling." | ||||||||||||||||||||||||||
--- | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
We've released a new profiling mode called **continuous profiling**. Read on to learn about the differences between transaction-based and continuous profiling mode. | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
## Historical Context | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
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. | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
This had the benefit of automatically profiling parts of the application that were actually instrumented while requiring no extra effort. This approach had drawbacks that continuous profiling aims to address - one of the most obvious ones being that profiles couldn't exceed 30-second durations. | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
In theory, transactions can be infinitely long since their duration doesn't impact payload size because start and end are represented by two timestamps. But profiles are different. Each stack sample that is collected by the profiler increases the payload size, which is why all Sentry SDKs had enforced a max profile duration of 30s. This limitation helps safeguard against large payloads that could harm your application performance. | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
This unfortunately, comes at the expense of limiting profiling capabilities, making it so that profiling isn't able to profile long-running tasks such as machine learning pipelines or build workflows. This feedback was the driving force behind continuous profiling. | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
The cap on max profile duration isn't the only drawback of transaction-based profiling. Another limitation is that the profiling data you collect will only ever be as good as the instrumentation you have. In other words, if there are parts of your application that you didn't instrument, the chance of you finding out that they're slowing down your application are near zero. | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
To address these limitations, we created a different profiling mode, one that doesn't impose constraints on profile durations and can surface parts of your application that might be slowing down your application even if you haven't instrumented them. | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
## Continuous Profiling Mode | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
In continuous profiling mode, the profiler runs continuously (no pun intended) and regularly flushes what we call "profile chunks" to the server. This enables us to extend profile durations and continuously profile your application. | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
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. | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
## SDK Differences | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
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.) | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
We recommend that you call the `startProfiling` method right after the Sentry SDK is initialized so that you gain visibility at the earliest point in your application lifecycle. From then on, the profiler will keep collecting profiles and sending chunks to Sentry until `stopProfiling` is called. | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
## Enabling transaction or continuous profiling mode | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
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. | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
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. | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
Here's an example of how to enable continuous profiling in NodeJS: | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
```javascript | ||||||||||||||||||||||||||
Sentry.Init({ | ||||||||||||||||||||||||||
dsn: "___PUBLIC_DSN___", | ||||||||||||||||||||||||||
integrations: [nodeProfilingIntegration()] | ||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
Sentry.profiler.startProfiling(); | ||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
If you wish to keep using transaction based profiling, then the options remain the same and you should either set profilesSampleRate or profilesSampler option on the SDK. | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
Example of enabling transaction based profiling in NodeJS | ||||||||||||||||||||||||||
Comment on lines
+54
to
+57
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
```javascript | ||||||||||||||||||||||||||
Sentry.Init({ | ||||||||||||||||||||||||||
dsn: "___PUBLIC_DSN___", | ||||||||||||||||||||||||||
profileSampleRate: 0.1 // profiles 10% of transactions | ||||||||||||||||||||||||||
integrations: [nodeProfilingIntegration()] | ||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
const transaction = Sentry.startTransaction(); | ||||||||||||||||||||||||||
//code executed between these two calls is subject to profiling | ||||||||||||||||||||||||||
transaction.finish(); | ||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
Note that while the profiling mode cannot be changed at runtime, it is fine for different projects or applications to use different profiling modes, or to switch modes. | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
## Differences in product experience | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
The major difference in product experience when using continuous profiling is that you will be able to visualize a flamegraph for your entire application, which means you can now take a step back from the previous transaction based view and look at your application's runtime as a whole. This makes it easier to for you to prioritize the functions that are slowing down your entire application and not just one particular transaction. | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
The product experience otherwise remains largely the same with entrypoints into profiling being supported from various parts of the performance product. | ||||||||||||||||||||||||||
Comment on lines
+72
to
+77
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.