Skip to content

Commit 3ac3846

Browse files
committed
Merge branch 'master' into indragiek/profiling-getting-started
2 parents e3950c5 + a98cad2 commit 3ac3846

File tree

2 files changed

+127
-0
lines changed

2 files changed

+127
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
title: Manage Your Continuous Profile Hours
3+
keywords: ["best practices"]
4+
sidebar_order: 51
5+
description: Learn how to use Sentry's tools to manage the amount of Continuous Profile hours you pay for.
6+
---
7+
8+
You can control when Continuous Profiling is active as well as use sampling to control the number of Continuous Profile hours you are billed for. See below to learn how.
9+
10+
## Before You Begin: Check Your Usage
11+
12+
You can look at your Continuous Profile hours in aggregate in the "Usage Stats" tab of the **Stats** page to understand the breakdown of your incoming profiles and see which projects are consuming your quota. This may help you figure out where you need to further fine-tune your configuration.
13+
14+
## How Can I Sample Profiles?
15+
16+
Continuous Profiling only supports **client-side** sampling. To control client-side sampling behavior, you can set the `profile_session_sample_rate` configuration parameter to a value between 0.0-1.0 to control the number of profiling sessions that are sampled (the default is 0.0.)
17+
18+
For Continuous Profiling, the session starts when the Sentry SDK is initialized and stops when the service or process is **terminated**. Sampling is only evaluated once during the process lifetime (during initialization).
19+
20+
For example: If you are using Continuous Profiling with a backend service where there are `N` instances of the same service that are deployed (such as containers or pods), the `profile_session_sample_rate` controls the percentage of those instances that will have profiling enabled. Setting the `profile_session_sample_rate` to 0.5 means that a randomly selected 50% of the `N` instances would have profiling enabled. This sampling rate will only be re-evaluated when the instance restarts or is re-deployed.
21+
22+
## How Can I Control When Profiling Is Active?
23+
24+
Continuous profiling provides two "lifecycle" modes that can be used to control when the profiler is running. These lifecycle modes are controlled by setting the `profile_lifecycle` SDK configuration option to one of two values:
25+
26+
- `manual` (default) - This provides fully manual control over when the profile is running. You can use the `start_profile_session` and `stop_profile_session` functions to precisely control this. Note that a profile session has to be sampled based on the value of `profile_session_sample_rate` for `start_profiler` to have any effect. Calling `start_profile_session` will have no effect on un-sampled sessions.
27+
28+
- `trace` - This provides a behavior similar to the previous transaction-based profiling product, where the profiler will automatically be started and stopped based on the trace lifecycle. In this mode, the profiler will automatically be started when there is at least one root span/transaction active, and automatically stopped when there are no root spans/transactions active. This lifecycle mode only works if both of the following conditions are met:
29+
30+
- The profile session is sampled (via `profile_session_sample_rate`)
31+
- The trace is sampled (via `traces_sample_rate` or `traces_sampler`)
32+
33+
## How Can I Estimate Usage For Continuous Profiling On The Backend?
34+
35+
To estimate monthly usage for Continuous Profiling when used on the backend, the calculation is **730 hours per month * the number of service instances being sampled**. For example, if service A has 5 instances and service B has 10 instances, the total usage would be **(5 + 10) instances x 730 hours = 10,950 hours per month.** In this context, an "instance" is a single deployment of the same service -- for example, you could have a single service that is deployed within N Kubernetes pods, and each pod would contain at least one instance of the service. Since each instance is independent of the others, they can be profiled independently. You can reduce cost by not profiling multiple instances of the same service (reducing `profile_session_sample_rate`) -- if they were to only profile 1 instance of each service in this example, it would be **2 instances * 730 hours = 1,460 hours per month.** If there are multiple services, customers could also choose to not profile services that are not performance sensitive (such as those with low throughput).
36+
37+
## How Do You Purchase Continuous Profiling?
38+
39+
Set your Pay-As-You-Go (PAYG) budget, which can be used to allocate spend towards Continuous Profiling and other Sentry products. See the [pricing docs](/pricing/) for more info.
40+
41+
## What If I'm Already Using Transaction-Based Profiling?
42+
43+
Continuous Profiling and the previous transaction-based profiling are **mutually exclusive** within the same service, meaning you **cannot** use both at the same time. If you are setting `profiles_sample_rate` or `profiles_sampler` in your Sentry SDK configuration options, you are using transaction-based profiling. If you are setting `profile_session_sample_rate`, you are using Continuous Profiling.
44+
45+
### What If I Try To Activate Both At Once?
46+
47+
If you set `profile_session_sample_rate` while either `profiles_sample_rate` or `profiles_sampler` are configured, `profile_session_sample_rate` will have no effect and transaction-based profiling will take precedence.
48+
49+
### Can I Use Both Transaction-Based Profiling and Continuous Profiling On Separate Services?
50+
51+
Across **separate** applications or services you **can** choose to use a mix of both transaction-based profiling APIs and the new Continuous Profiling APIs. We recommend that all users migrate to Continuous Profiling APIs, since transaction-based APIs will eventually be deprecated and removed in a major SDK release. We will continue to support ingesting transaction-based profiles sent by older SDKs for backward compatibility.
52+
53+
## How Do I Migrate From Transaction-Based Profiling to Continuous Profiling?
54+
55+
- Replace usage of `profiles_sample_rate` and `profiles_sampler` with `profile_session_sample_rate`
56+
- If you're using the `manual` profile lifecycle mode, add calls to `start_profile_session` and `stop_profile_session`
57+
- If you're using the `trace` profile lifecycle mode, ensure that `traces_sample_rate` or `traces_sampler` are configured appropriately in addition to `profile_session_sample_rate`
58+
59+
See the detailed [migration guide](/) for more information.
60+
61+
{/* TODO: Add link above */}
62+
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
title: Continuous & UI Profiling Migration Guide
3+
sidebar_order: 150
4+
description: "Learn how to migrate from the older transaction-based Profiling API to the new Continuous and UI Profiling APIs."
5+
---
6+
7+
To learn more about the conceptual difference between the previous transaction-based and the new Continuous Profiling and UI Profiling products, please see [the Transaction vs Continuous Profiling docs](/product/explore/profiling/transaction-vs-continuous-profiling/). To summarize, the key differences are:
8+
9+
- Transaction-based profiling was bound to the lifecycle of a trace. Profiling only occurred during a transaction or root span and could not be started independently. **Continuous and UI Profiling support both a trace-bound lifecycle mode, and a manual lifecycle mode that allows you to directly control the profiler using start/stop APIs**.
10+
- Transaction-based profiles were limited at 30 seconds in length. **Continuous and UI Profiling support arbitrarily long profiles.**
11+
12+
This guide will focus on how to migrate your instrumentation from transaction-based profiling to Continuous Profiling and UI Profiling, and explain the billing implications of migrating. We plan to eventually deprecate the transaction-based API, so we recommend that you migrate to the new APIs as soon as possible.
13+
14+
For the remainder of this document, you can assume that wherever “Continuous/UI Profiling” is referenced, the same guidance applies to both the Continuous Profiling (backend-oriented) and UI Profiling (frontend-oriented) products, even though they are targeted at different use cases.
15+
16+
## Availability
17+
18+
Continuous Profiling is supported on the following SDKs:
19+
20+
- [Python](/platforms/python/profiling/) `2.24.1`
21+
- [Node.js](/platforms/javascript/guides/node/profiling/) `9.8.0`
22+
23+
UI Profiling is supported on the following SDKs:
24+
25+
- [iOS & macOS](/platforms/apple/profiling/) *version TBD*
26+
- [Android (Java & Kotlin only)](/platforms/android/profiling/) `8.5.0`
27+
28+
If you are using any other SDKs that currently support transaction-based profiling, those SDKs do not yet support Continuous or UI Profiling. We will be adding support for more SDKs over time.
29+
30+
## Identifying Current API Usage
31+
32+
If you are specifying either the `profiles_sample_rate` or `profiles_sampler` configuration options, you are using transaction-based profiling.
33+
34+
If you are specifying the `profile_session_sample_rate` and/or `profile_lifecycle` configuration options, you are using Continuous Profiling or UI Profiling.
35+
36+
## Migrating to Continuous/UI Profiling
37+
38+
### 1. Replace the `profiles_sample_rate` and `profiles_sampler` SDK configuration options with `profile_session_sample_rate`
39+
40+
There is an important distinction in how client-side sampling is implemented between transaction-based and Continuous/UI Profiling. `profiles_sample_rate` and `profiles_sampler` were used to evaluate whether the profile would be sampled *for each transaction*. In other words, if `profiles_sample_rate` was set to 0.5, 50% of all transactions would have associated profiles. `profiles_sampler` worked similarly — the only difference was that you could implement custom sampling logic (rather than a fixed sample rate) based on the context of the transaction being sampled.
41+
42+
In contrast, Continuous/UI Profiling use client-side sampling that is *session scoped,* configured via the new `profile_session_sample_rate` parameter. Sampling is evaluated once at the beginning of each session, not every time profiling data is collected. Since the scope at which sampling is applied is different, you can’t just directly translate the previous `profiles_sample_rate` value to `profile_session_sample_rate`.
43+
44+
To control client side sampling behavior, set the `profile_session_sample_rate` configuration parameter to a value from 0.0-1.0 (default is 0.0) to control the number of profiling sessions that are sampled. The way this sampling rate is applied depends on the context:
45+
46+
- **For Continuous Profiling**: the session starts when the Sentry SDK is initialized, and stops when the service or process is terminated. Sampling is only evaluated once during the process lifetime (during initialization.)
47+
- For example, if you are using Continuous Profiling with a backend service where there are N instances of the same service that are deployed (such as N containers, pods, etc.), the `profile_session_sample_rate` controls the percentage of those instances that will have profiling enabled. 0.5 would mean that a randomly sampled 50% of the N instances would have profiling enabled.
48+
- Sampling would only be re-evaluated once an instance restarts or is re-deployed
49+
- **For UI Profiling:** the initial user session starts when the Sentry SDK is initialized, and sampling is first evaluated at this point. The user session will either end on termination of the application *OR*, depending on the platform, there can be other events that end a user session (for example backgrounding a mobile application). The sampling rate will be re-evaluated on each new user session.
50+
- For example, on the browser, the user session begins when the tab is opened and ends when the tab is closed. The sampling will be evaluated once at the start of each session, so if `profile_session_sample_rate` is set to 0.5, then 50% of the time your application is opened in a tab, profiling will be active for that tab’s lifetime.
51+
- On mobile, the user session begins when the application is started or foregrounded, and ends when the application is terminated or backgrounded. The sampling will be evaluated once at the start of each session, so if `profile_session_sample_rate` is set to 0.5 then 50% of the time the user opens your mobile app, profiling will be active until the user backgrounds or quits the app.
52+
53+
### 2. Set the new `profile_lifecycle` SDK configuration option
54+
55+
Continuous/UI Profiling support two lifecycle modes: `manual` and `trace`.
56+
57+
**`manual` is the default mode** and allows you to more directly control when the profiler is running by calling the `start_profile_session` and `stop_profile_session` functions. If you decide to use this mode, you must add these start/stop calls anywhere in your code that you want profiling to be active. If `start_profile_session` is not called, profiling will never occur. Note that this respects `profile_session_sample_rate` — if the session is not sampled, no profiling data will be collected even if `start_profile_session` is called.
58+
59+
**If you want a more automated profiling behavior that is analogous to the previous transaction-based profiling behavior, you can use the `trace` lifecycle mode.** In this mode, you don’t need to manually call `start_profile_session` and `stop_profile_session` because profiling will automatically be started and stopped whenever there is an active transaction or root span. This mode respects `profile_session_sample_rate` as the `manual` lifecycle mode does, but also respects `traces_sample_rate` and `traces_sampler` — in order for profiling to occur, the profiling session must be sampled, and the trace must be sampled as well.
60+
61+
## Updating Your Subscription
62+
63+
Access to Continuous/UI Profiling is only available through your pay-as-you-go (PAYG) budget. To set-up a PAYG budget or make changes to your existing PAYG budget please go to your [**Settings**](https://sentry.io/orgredirect/organizations/:orgslug/settings/) page and click on "Subscription" (under the "Usage & Billing" heading.) See our [**pricing docs**](/pricing/) for more information.
64+
65+
You can see the number of Continuous and/or UI Profile Hours of your transaction-based profiles by visiting the Stats page to help estimate the profiling hours you will need when migrating.

0 commit comments

Comments
 (0)