diff --git a/src/includes/performance/automatic-performance-metrics/javascript.mdx b/src/includes/performance/automatic-performance-metrics/javascript.mdx new file mode 100644 index 0000000000000..f47e9614f632f --- /dev/null +++ b/src/includes/performance/automatic-performance-metrics/javascript.mdx @@ -0,0 +1,9 @@ +The JavaScript Browser SDKs automatically collect the following performance metrics: + +- First Paint: `fp` +- First Contentful Paint: `fcp` +- Largest Contentful Paint: `lcp` +- First Input Delay: `fid` +- Cumulative Layout Shift: `cls` +- Time to First Byte: `ttfb` +- Time to First Byte Request Time: `ttfb.requesttime` diff --git a/src/includes/performance/custom-performance-metrics/javascript.mdx b/src/includes/performance/custom-performance-metrics/javascript.mdx new file mode 100644 index 0000000000000..f0fbe670e3ad8 --- /dev/null +++ b/src/includes/performance/custom-performance-metrics/javascript.mdx @@ -0,0 +1,14 @@ +Supported in Sentry's JavaScript SDK version `7.0.0` and above. + +```javascript +const transaction = Sentry.getCurrentHub().getScope().getTransaction(); + +// Record amount of memory used +transaction.setMeasurement('memoryUsed', 123, 'byte'); + +// Record time when Footer component renders on page +transaction.setMeasurement('ui.footerComponent.render', 1.3, 'second'); + +// Record amount of times localStorage was read +transaction.setMeasurement('localStorageRead', 4); +``` diff --git a/src/platforms/common/performance/instrumentation/performance-metrics.mdx b/src/platforms/common/performance/instrumentation/performance-metrics.mdx new file mode 100644 index 0000000000000..730e6290cc3e1 --- /dev/null +++ b/src/platforms/common/performance/instrumentation/performance-metrics.mdx @@ -0,0 +1,91 @@ +--- +title: Performance Metrics +sidebar_order: 20 +supported: + - javascript +notSupported: + - javascript.cordova + - javascript.electron + - react-native + - dotnet + - python + - go + - java + - android + - ruby + - java.spring-boot + - apple + - unity + - dart + - flutter + - rust + - native + - php + - native.breakpad + - native.crashpad + - native.minidumps + - unreal + - native.wasm +description: "Learn how to attach performance metrics to your transactions." +--- + +Sentry's SDKs support sending performance metrics data to Sentry. These are numeric values attached to transactions that are aggregated and displayed in Sentry. + + + +In addition to automatic performance metrics, the SDK supports setting custom performance metrics on transactions. This allows you to define metrics that are important to your application and send them to Sentry. + +To set a performance metric, you need to supply the following: +- name (`string`) +- value (any numeric type - `float`, `integer`, etc.) +- unit (`string`, can be empty or the string `'none'`). + +Sentry supports adding arbitrary custom units, but we recommend using one of the [supported units listed below](./#supported-performance-metric-units). + + + + + +For the moment, 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. + + + +## Supported Performance Metric Units + +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, etc. - based on those units. For values that are unitless, you can supply an empty string or `none`. + +### Duration Units + +- `nanosecond` +- `microsecond` +- `millisecond` +- `second` +- `minute` +- `hour` +- `day` +- `week` + +### Information Units + +- `bit` +- `byte` +- `kilobyte` +- `kibibyte` +- `megabyte` +- `mebibyte` +- `gigabyte` +- `gibibyte` +- `terabyte` +- `tebibyte` +- `petabyte` +- `petabyte` +- `pebibyte` +- `exabyte` +- `exbibyte` + +## Fraction Units + +- `ratio` +- `percent` + +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).