Performance Metrics
Sentry's SDKs support sending performance metrics data to Sentry. These are numeric values attached to transactions that are aggregated and displayed in Sentry.
Custom Metrics
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
, Defaults to the stringnone
if omitted.)
Sentry supports adding arbitrary custom units, but we recommend using one of the supported units listed below.
Adding custom metrics is supported in Sentry's JavaScript SDK version 7.0.0
and above.
const transaction = Sentry.getCurrentScope().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);
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.
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, and so on