Skip to content

Commit b4ed274

Browse files
markushiimatwawanaphilipphofmann
authored
feat(java): Add automatic and custom performance metrics doc (#5604)
* feat(java): Add custom performance metrics doc * feat(android): Add doc for automatic performance metrics * Update src/platform-includes/performance/automatic-performance-metrics/android.mdx Co-authored-by: Isabel <[email protected]> * Update src/platform-includes/performance/automatic-performance-metrics/android.mdx Co-authored-by: Isabel <[email protected]> * Update src/platform-includes/performance/automatic-performance-metrics/android.mdx Co-authored-by: Philipp Hofmann <[email protected]> Co-authored-by: Isabel <[email protected]> Co-authored-by: Philipp Hofmann <[email protected]>
1 parent 196d660 commit b4ed274

File tree

3 files changed

+44
-4
lines changed

3 files changed

+44
-4
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
If configured, the Android SDK automatically collects the following performance metrics:
2+
3+
* Cold and warm app start time - learn more in [App Start Instrumentation](/platforms/android/performance/instrumentation/automatic-instrumentation/#app-start-instrumentation).
4+
* Frozen and slow frame rendering - learn more in [Slow and Frozen Frames](/platforms/android/performance/instrumentation/automatic-instrumentation/#slow-and-frozen-frames).
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Adding custom metrics is supported in Sentry's Java SDK version `6.5.0` and above.
2+
3+
```java {tabTitle:Java}
4+
import io.sentry.ISpan;
5+
import io.sentry.MeasurementUnit;
6+
import io.sentry.Sentry;
7+
8+
final ISpan span = Sentry.getSpan();
9+
if (span != null) {
10+
// Record amount of memory used
11+
span.setMeasurement("memory_used", 64, MeasurementUnit.Information.MEGABYTE);
12+
13+
// Record time it took to load user profile
14+
span.setMeasurement("user_profile_loading_time", 1.3, MeasurementUnit.Duration.SECOND);
15+
16+
// Record number of times the screen was loaded
17+
span.setMeasurement("screen_load_count", 4);
18+
}
19+
```
20+
21+
22+
```kotlin {tabTitle:Kotlin}
23+
import io.sentry.MeasurementUnit
24+
import io.sentry.Sentry
25+
26+
val span = Sentry.getSpan()
27+
28+
// Record amount of memory used
29+
span?.setMeasurement("memory_used", 64, MeasurementUnit.Information.MEGABYTE)
30+
31+
// Record time it took to load user profile
32+
span?.setMeasurement("user_profile_loading_time", 1.3, MeasurementUnit.Duration.SECOND)
33+
34+
// Record number of times the screen was loaded
35+
span?.setMeasurement("screen_load_count", 4)
36+
```

src/platforms/common/performance/instrumentation/performance-metrics.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ supported:
77
- dart
88
- flutter
99
- react-native
10+
- java
11+
- java.spring-boot
12+
- android
1013
notSupported:
1114
- javascript.cordova
1215
- javascript.electron
1316
- dotnet
1417
- go
15-
- java
16-
- android
1718
- ruby
18-
- java.spring-boot
1919
- apple
2020
- unity
2121
- rust
@@ -31,7 +31,7 @@ description: "Learn how to attach performance metrics to your transactions."
3131

3232
Sentry's SDKs support sending performance metrics data to Sentry. These are numeric values attached to transactions that are aggregated and displayed in Sentry.
3333

34-
<PlatformSection supported={["javascript"]} notSupported={["react-native"]}>
34+
<PlatformSection supported={["javascript", "android"]} notSupported={["react-native"]}>
3535

3636
<PlatformContent includePath="performance/automatic-performance-metrics" />
3737

0 commit comments

Comments
 (0)