From b4023fee8a134d1184d3a13c2e6f3b8335c04d4a Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Tue, 28 Jan 2025 15:29:47 -0800 Subject: [PATCH 1/2] Update RN Custom Metrics to use `Sentry.setMeasurement` --- .../instrumentation/performance-metrics.mdx | 18 ++++++++++++++++-- .../react-native.mdx | 6 ------ .../react-native.mdx | 16 ---------------- 3 files changed, 16 insertions(+), 24 deletions(-) delete mode 100644 platform-includes/performance/automatic-performance-metrics/react-native.mdx delete mode 100644 platform-includes/performance/custom-performance-metrics/react-native.mdx diff --git a/docs/platforms/react-native/tracing/instrumentation/performance-metrics.mdx b/docs/platforms/react-native/tracing/instrumentation/performance-metrics.mdx index 854f3707b8467..b1c6ba17cdb02 100644 --- a/docs/platforms/react-native/tracing/instrumentation/performance-metrics.mdx +++ b/docs/platforms/react-native/tracing/instrumentation/performance-metrics.mdx @@ -6,7 +6,12 @@ sidebar_order: 20 Sentry's SDKs support sending performance metrics data to Sentry. These are numeric values attached to transactions that are aggregated and displayed in Sentry. - +If configured, the React Native SDK automatically collects the following performance metrics: + +- Cold and warm app start time + . +- Slow and frozen frame rendering + . ## Custom Measurements @@ -20,7 +25,16 @@ To set a performance measurement, you need to supply the following: Sentry supports adding arbitrary custom units, but we recommend using one of the [supported units listed below](./#supported-measurement-units). - +```javascript +// Record amount of memory used +Sentry.setMeasurement("memoryUsed", 123, "byte"); + +// Record time when Footer component renders on page +Sentry.setMeasurement("ui.footerComponent.render", 1.3, "second"); + +// Record amount of times localStorage was read +Sentry.setMeasurement("localStorageRead", 4); +``` diff --git a/platform-includes/performance/automatic-performance-metrics/react-native.mdx b/platform-includes/performance/automatic-performance-metrics/react-native.mdx deleted file mode 100644 index e557200c6886a..0000000000000 --- a/platform-includes/performance/automatic-performance-metrics/react-native.mdx +++ /dev/null @@ -1,6 +0,0 @@ -If configured, the React Native SDK automatically collects the following performance metrics: - -- Cold and warm app start time - . -- Slow and frozen frame rendering - . diff --git a/platform-includes/performance/custom-performance-metrics/react-native.mdx b/platform-includes/performance/custom-performance-metrics/react-native.mdx deleted file mode 100644 index 11c3c45dd0b52..0000000000000 --- a/platform-includes/performance/custom-performance-metrics/react-native.mdx +++ /dev/null @@ -1,16 +0,0 @@ -Adding custom measurements is supported in Sentry's React Native SDK version `4.0.0` and above. - -```javascript -import * as Sentry from "@sentry/react-native"; - -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); -``` From c2e754bba6a13b8f0ac3d2beb726d093be474045 Mon Sep 17 00:00:00 2001 From: Krystof Woldrich <31292499+krystofwoldrich@users.noreply.github.com> Date: Mon, 3 Feb 2025 22:41:22 +0100 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Alex Krawiec --- .../tracing/instrumentation/performance-metrics.mdx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/platforms/react-native/tracing/instrumentation/performance-metrics.mdx b/docs/platforms/react-native/tracing/instrumentation/performance-metrics.mdx index b1c6ba17cdb02..57947bbb1be35 100644 --- a/docs/platforms/react-native/tracing/instrumentation/performance-metrics.mdx +++ b/docs/platforms/react-native/tracing/instrumentation/performance-metrics.mdx @@ -6,12 +6,10 @@ sidebar_order: 20 Sentry's SDKs support sending performance metrics data to Sentry. These are numeric values attached to transactions that are aggregated and displayed in Sentry. -If configured, the React Native SDK automatically collects the following performance metrics: +The React Native SDK automatically collects the following performance metrics: - Cold and warm app start time - . - Slow and frozen frame rendering - . ## Custom Measurements