Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a0e8689

Browse files
committedFeb 22, 2024
more docs
1 parent 33cc834 commit a0e8689

File tree

9 files changed

+199
-0
lines changed

9 files changed

+199
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: Set Up Performance
3+
description: "Learn how to enable performance monitoring in your app if it is not already set up."
4+
sidebar_order: 4000
5+
---
6+
7+
With [performance monitoring](/product/performance/), Sentry tracks your software performance, measuring metrics like throughput and latency, and displaying the impact of errors across multiple systems. Sentry captures distributed traces consisting of transactions and spans, which measure individual services and individual operations within those services. Learn more about our model in [Distributed Tracing](/product/sentry-basics/tracing/distributed-tracing/).
8+
9+
<Note>
10+
11+
If you’re adopting Performance in a high-throughput environment, we recommend testing prior to deployment to ensure that your service’s performance characteristics maintain expectations.
12+
13+
</Note>
14+
15+
## Configure
16+
17+
First, enable tracing and configure the sampling rate for transactions. Set the sample rate for your transactions by either:
18+
19+
- Setting a uniform sample rate for all transactions using the <PlatformIdentifier name="traces-sample-rate" /> option in your SDK config to a number between `0` and `1`. (For example, to send 20% of transactions, set <PlatformIdentifier name="traces-sample-rate" /> to `0.2`.)
20+
- Controlling the sample rate based on the transaction itself and the context in which it's captured, by providing a function to the <PlatformIdentifier name="traces-sampler" /> config option.
21+
22+
The two options are meant to be mutually exclusive. If you set both, <PlatformIdentifier name="traces-sampler" /> will take precedence.
23+
24+
<PlatformContent includePath="performance/configure-sample-rate" />
25+
26+
Learn more about performance monitoring <PlatformLink to="/configuration/options/#tracing-options">options</PlatformLink>, or how to <PlatformLink to="/configuration/sampling/#sampling-transaction-events">sample transactions</PlatformLink>.
27+
28+
## Verify
29+
30+
Test out tracing by starting and finishing a transaction, which you _must_ do so transactions can be sent to Sentry. Learn how in our <PlatformLink to="/performance/instrumentation/custom-instrumentation/">Custom Instrumentation</PlatformLink> content.
31+
32+
While you're testing, set <PlatformIdentifier name="traces-sample-rate" /> to `1.0`, as that ensures that every transaction will be sent to Sentry.
33+
34+
Once testing is complete, you may want to set a lower <PlatformIdentifier name="traces-sample-rate" /> value, or switch to using <PlatformIdentifier name="traces-sampler" /> to selectively sample and filter your transactions, based on contextual data.
35+
36+
## Next Steps
37+
38+
<PageGrid />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: Custom Instrumentation
3+
description: "Learn how to capture performance data on any action in your app."
4+
sidebar_order: 20
5+
---
6+
7+
<Note>
8+
9+
To capture transactions and spans customized to your organization's needs, you must first <PlatformLink to="/performance/">set up performance monitoring.</PlatformLink>
10+
11+
</Note>
12+
13+
<PlatformContent includePath="performance/enable-manual-instrumentation" />
14+
15+
<PlatformContent includePath="performance/add-spans-example" />
16+
17+
<PlatformContent includePath="performance/retrieve-transaction" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: Instrumentation
3+
description: "Learn how to instrument performance in your app."
4+
sidebar_order: 20
5+
---
6+
7+
Instrumenting performance monitoring is specific to your SDK.
8+
9+
<PageGrid />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
title: Performance Metrics
3+
description: "Learn how to attach performance metrics to your transactions."
4+
sidebar_order: 20
5+
---
6+
7+
Sentry's SDKs support sending performance metrics data to Sentry. These are numeric values attached to transactions that are aggregated and displayed in Sentry.
8+
9+
## Custom Metrics
10+
11+
In addition to automatic performance metrics, the SDK supports setting [custom performance metrics](/product/performance/metrics/#custom-performance-metrics) on transactions. This allows you to define metrics that are important to your application and send them to Sentry.
12+
13+
To set a performance metric, you need to supply the following:
14+
15+
- name (`string`)
16+
- value (any numeric type - `float`, `integer`, etc.)
17+
- unit (`string`, Defaults to the string `none` if omitted.)
18+
19+
Sentry supports adding arbitrary custom units, but we recommend using one of the [supported units listed below](./#supported-performance-metric-units).
20+
21+
<PlatformContent includePath="performance/custom-performance-metrics" />
22+
23+
<Note>
24+
25+
Currently, unit conversion is only supported once the data has already been stored. This means that, for example, `('myMetric', 60, 'second')` and `('myMetric', 3, 'minute')` would not be aggregated, but rather stored as two separate metrics. To avoid this, make sure to use a consistent unit when recording a custom metric.
26+
27+
</Note>
28+
29+
## Supported Performance Metric Units
30+
31+
Units augment metric values by giving meaning to what otherwise might be abstract numbers. Adding units also allows Sentry to offer controls - unit conversions, filters, and so on - based on those units. For values that are unitless, you can supply an empty string or `none`.
32+
33+
### Duration Units
34+
35+
- `nanosecond`
36+
- `microsecond`
37+
- `millisecond`
38+
- `second`
39+
- `minute`
40+
- `hour`
41+
- `day`
42+
- `week`
43+
44+
### Information Units
45+
46+
- `bit`
47+
- `byte`
48+
- `kilobyte`
49+
- `kibibyte`
50+
- `megabyte`
51+
- `mebibyte`
52+
- `gigabyte`
53+
- `gibibyte`
54+
- `terabyte`
55+
- `tebibyte`
56+
- `petabyte`
57+
- `pebibyte`
58+
- `exabyte`
59+
- `exbibyte`
60+
61+
### Fraction Units
62+
63+
- `ratio`
64+
- `percent`
65+
66+
If you want to explore further, you can find details about supported units in our [event ingestion documentation](https://getsentry.github.io/relay/relay_metrics/enum.MetricUnit.html).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
You can add individual spans to a transaction by calling the `StartChild` method on a transaction.
2+
This method returns a new `SentrySpan` object that you can use to record the duration of the operation that the span represents.
3+
When you're done with the operation, you can call the `Finish` method on the span to mark it as finished.
4+
5+
```powershell
6+
# Transaction can be started by providing, at minimum, the name and the operation
7+
$transaction = Start-SentryTransaction 'test-transaction-name' 'test-transaction-operation'
8+
9+
# Transactions can have child spans (and those spans can have child spans as well)
10+
$span = $transaction.StartChild("test-child-operation")
11+
# ...
12+
# (Perform the operation represented by the span/transaction)
13+
# ...
14+
$span.Finish() # Mark the span as finished
15+
16+
$span = $transaction.StartChild("another-span")
17+
# ...
18+
$span.Finish()
19+
20+
21+
$transaction.Finish() # Mark the transaction as finished and send it to Sentry
22+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
```powershell
2+
Start-Sentry {
3+
# Example uniform sample rate: capture 100% of transactions
4+
$_.TracesSampleRate = 1.0
5+
}
6+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
The following example shows how to set custom metrics on a `transaction`, including how obtain the current `span` and get its `transaction`.
2+
If you already have the `transaction` or `span`, you can use it directly.
3+
4+
```powershell
5+
# Record amount of memory used
6+
[Sentry.SpanDataExtensions]::SetMeasurement($transaction, 'memory_used', 64, [Sentry.MeasurementUnit+Information]::Megabyte)
7+
8+
# Record time it took to load user profile
9+
[Sentry.SpanDataExtensions]::SetMeasurement($transaction, 'user_profile_loading_time', 1.3, [Sentry.MeasurementUnit+Duration]::Second)
10+
11+
# Record number of times the screen was loaded
12+
[Sentry.SpanDataExtensions]::SetMeasurement($transaction, 'screen_load_count', 4)
13+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
To instrument certain regions of your code, you can create transactions to capture them.
2+
3+
```powershell
4+
# Transaction can be started by providing, at minimum, the name and the operation
5+
$transaction = Start-SentryTransaction 'test-transaction-name' 'test-transaction-operation'
6+
7+
# ...
8+
# (Perform the operation represented by the span/transaction)
9+
# ...
10+
11+
$transaction.Finish() # Mark the transaction as finished and send it to Sentry
12+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## Retrieve a Transaction
2+
3+
In cases where you want to attach Spans to an already ongoing Transaction you can use `SentrySdk.GetSpan()`. If there is a running Transaction or Span currently on the scope, this method will return a `SentryTransaction` or `SentrySpan`; otherwise, it returns `$null`.
4+
5+
```powershell
6+
$span = [Sentry.SentrySdk]::GetSpan()
7+
8+
if ($null -eq $span)
9+
{
10+
$span = Start-SentryTransaction 'task' 'op'
11+
}
12+
else
13+
{
14+
$span = $span.StartChild('subtask')
15+
}
16+
```

0 commit comments

Comments
 (0)
Please sign in to comment.