Performance Metrics
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.
Custom performance measurements are limited to 10 per transaction. If you have more than 10 measurements per transaction, the list will be truncated. For a more flexible solution, we recommend using custom metrics instead.
In addition to automatic performance metrics, the SDK supports setting custom performance measurements on transactions. This allows you to define measurements that are important to your application and send them to Sentry.
To set a performance measurement, you need to supply the following:
- name (
string) - value (any numeric type -
float,integer, etc.) - unit (
string, defaults to the stringnoneif omitted)
Sentry supports adding arbitrary custom units, but we recommend using one of the supported units listed below.
Adding custom measurements is supported in Sentry's .NET SDK, version 3.23.0 and above.
The following example shows how to set custom measurements on a transaction, including how obtain the current span and get its transaction. If you already have the transaction or span, you can use it directly.
var span = SentrySdk.GetSpan(); // or hub.GetSpan()
if (span != null)
{
var transaction = span.GetTransaction();
// Record amount of memory used
transaction.SetMeasurement("memory_used", 64, MeasurementUnit.Information.Megabyte);
// Record time it took to load user profile
transaction.SetMeasurement("user_profile_loading_time", 1.3, MeasurementUnit.Duration.Second);
// Record number of times the screen was loaded
transaction.SetMeasurement("screen_load_count", 4);
}
Currently, unit conversion is only supported once the data has already been stored. This means that, for example, ('myMeasurement', 60, 'second') and ('myMeasurement', 3, 'minute') would not be aggregated, but rather stored as two separate measurements. To avoid this, make sure to use a consistent unit when recording a custom measurement.
Units augment measurement 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.
nanosecondmicrosecondmillisecondsecondminutehourdayweek
bitbytekilobytekibibytemegabytemebibytegigabytegibibyteterabytetebibytepetabytepebibyteexabyteexbibyte
ratiopercent
If you want to explore further, you can find details about supported units in our event ingestion documentation.
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").