From bf7413d959dbc5816205f9bbb2fbf098bbfdb692 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Wed, 5 Oct 2022 08:57:33 +0200 Subject: [PATCH 1/3] Add custom metrics docs for Dart and Flutter --- .../custom-performance-metrics/dart.mdx | 18 ++++++++++++++++++ .../custom-performance-metrics/javascript.mdx | 12 +++++++----- .../instrumentation/performance-metrics.mdx | 6 ++---- 3 files changed, 27 insertions(+), 9 deletions(-) create mode 100644 src/platform-includes/performance/custom-performance-metrics/dart.mdx diff --git a/src/platform-includes/performance/custom-performance-metrics/dart.mdx b/src/platform-includes/performance/custom-performance-metrics/dart.mdx new file mode 100644 index 00000000000000..92ce437adcf26e --- /dev/null +++ b/src/platform-includes/performance/custom-performance-metrics/dart.mdx @@ -0,0 +1,18 @@ +Adding custom metrics is supported in Sentry's Dart/Flutter SDK version `6.11.0` and above. + +```dart +import 'package:sentry/sentry.dart'; + +final transaction = Sentry.getSpan(); + +// Record amount of memory used +transaction?.setMeasurement('memoryUsed', 123, + unit: SentryMeasurementUnit.byte); + +// Record time when Footer component renders on page +transaction?.setMeasurement('ui.footerComponent.render', 1.3, + unit: SentryMeasurementUnit.second); + +// Record amount of times localStorage was read +transaction?.setMeasurement('localStorageRead', 4); +``` diff --git a/src/platform-includes/performance/custom-performance-metrics/javascript.mdx b/src/platform-includes/performance/custom-performance-metrics/javascript.mdx index 92baab7dc79366..176b9d1154da0c 100644 --- a/src/platform-includes/performance/custom-performance-metrics/javascript.mdx +++ b/src/platform-includes/performance/custom-performance-metrics/javascript.mdx @@ -1,14 +1,16 @@ Adding custom metrics is supported in Sentry's JavaScript SDK version `7.0.0` and above. -```javascript -const transaction = Sentry.getCurrentHub().getScope().getTransaction(); +```dart + final transaction = Sentry.getSpan(); // Record amount of memory used -transaction.setMeasurement('memoryUsed', 123, 'byte'); + transaction?.setMeasurement('memoryUsed', 123, + unit: SentryMeasurementUnit.byte); // Record time when Footer component renders on page -transaction.setMeasurement('ui.footerComponent.render', 1.3, 'second'); + transaction?.setMeasurement('ui.footerComponent.render', 1.3, + unit: SentryMeasurementUnit.second); // Record amount of times localStorage was read -transaction.setMeasurement('localStorageRead', 4); + transaction?.setMeasurement('localStorageRead', 4); ``` diff --git a/src/platforms/common/performance/instrumentation/performance-metrics.mdx b/src/platforms/common/performance/instrumentation/performance-metrics.mdx index f32be1287c533d..a0bc6f61475faa 100644 --- a/src/platforms/common/performance/instrumentation/performance-metrics.mdx +++ b/src/platforms/common/performance/instrumentation/performance-metrics.mdx @@ -4,10 +4,10 @@ sidebar_order: 20 supported: - javascript - python + - dart notSupported: - javascript.cordova - javascript.electron - - react-native - dotnet - go - java @@ -16,8 +16,6 @@ notSupported: - java.spring-boot - apple - unity - - dart - - flutter - rust - native - php @@ -31,7 +29,7 @@ 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. - + From 196195734b0de58cb1f5e4e15111693257f7b2f1 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Wed, 5 Oct 2022 08:59:20 +0200 Subject: [PATCH 2/3] fix --- .../custom-performance-metrics/javascript.mdx | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/platform-includes/performance/custom-performance-metrics/javascript.mdx b/src/platform-includes/performance/custom-performance-metrics/javascript.mdx index 176b9d1154da0c..92baab7dc79366 100644 --- a/src/platform-includes/performance/custom-performance-metrics/javascript.mdx +++ b/src/platform-includes/performance/custom-performance-metrics/javascript.mdx @@ -1,16 +1,14 @@ Adding custom metrics is supported in Sentry's JavaScript SDK version `7.0.0` and above. -```dart - final transaction = Sentry.getSpan(); +```javascript +const transaction = Sentry.getCurrentHub().getScope().getTransaction(); // Record amount of memory used - transaction?.setMeasurement('memoryUsed', 123, - unit: SentryMeasurementUnit.byte); +transaction.setMeasurement('memoryUsed', 123, 'byte'); // Record time when Footer component renders on page - transaction?.setMeasurement('ui.footerComponent.render', 1.3, - unit: SentryMeasurementUnit.second); +transaction.setMeasurement('ui.footerComponent.render', 1.3, 'second'); // Record amount of times localStorage was read - transaction?.setMeasurement('localStorageRead', 4); +transaction.setMeasurement('localStorageRead', 4); ``` From e4e1846b47f85d12d9fb7ee931c7b7ea379d6736 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Wed, 5 Oct 2022 09:38:30 +0200 Subject: [PATCH 3/3] fix --- .../performance/instrumentation/performance-metrics.mdx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/platforms/common/performance/instrumentation/performance-metrics.mdx b/src/platforms/common/performance/instrumentation/performance-metrics.mdx index a0bc6f61475faa..3121197656ccaf 100644 --- a/src/platforms/common/performance/instrumentation/performance-metrics.mdx +++ b/src/platforms/common/performance/instrumentation/performance-metrics.mdx @@ -5,6 +5,8 @@ supported: - javascript - python - dart + - flutter + - react-native notSupported: - javascript.cordova - javascript.electron @@ -49,7 +51,7 @@ 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'`). +- unit (`string`, Defaults to the string `none` if omitted.) Sentry supports adding arbitrary custom units, but we recommend using one of the [supported units listed below](./#supported-performance-metric-units).