You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/platforms/android/common/performance/instrumentation/automatic-instrumentation.mdx
+100Lines changed: 100 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -223,3 +223,103 @@ The span finishes once the operation has been executed. The span `status` is set
223
223
When the operation throws an `Exception`, Sentry's SDK associates this exception to the running span. If you haven't set the SDK to swallow the exception and capture it, the span and SentryEvent will be linked when viewing it on the **Issue Details** page in sentry.io.
224
224
225
225
For more information see our [file I/O integration](/platforms/android/configuration/integrations/file-io/).
226
+
227
+
### User Interaction Instrumentation
228
+
229
+
_(New in version 6.0.0)_
230
+
231
+
The UI instrumentation, once enabled, captures transactions for a set of different user interactions, which include clicks, scrolls and swipes. The SDK composes the transaction name out of the host `Activity` and the `id` of the view, which captured the user interaction; for example, `LoginActivity.login_button`. The transaction operation is set to `ui.action` plus the interaction type (one of `click`, `scroll` or `swipe`).
232
+
233
+
<Note>
234
+
235
+
If the view doesn't have the `id` assigned, the transaction won't be captured because it can't be uniquely identified otherwise.
236
+
237
+
</Note>
238
+
239
+
The UI instrumentation is disabled by default, but you can enable it by setting:
The transaction finishes automatically after it reaches the specified [idleTimeout](/platforms/android/configuration/options/#idle-timeout) and all of its child spans are finished. The `idleTimeoout` defaults to `3000` milliseconds (three seconds). You can also disable the idle timeout by setting it to `null`, but the transaction must be finished manually in this case.
248
+
249
+
<Note>
250
+
251
+
If the UI transaction has idled, but didn't have any child spans added, it will be dropped.
252
+
253
+
</Note>
254
+
255
+
To finish the transaction manually, you can:
256
+
257
+
```java
258
+
importio.sentry.Sentry;
259
+
260
+
ISpan span =Sentry.getSpan();
261
+
if (span !=null) {
262
+
span.finish();
263
+
}
264
+
```
265
+
266
+
```kotlin
267
+
importio.sentry.Sentry
268
+
269
+
val span =Sentry.getSpan()
270
+
span?.finish()
271
+
```
272
+
273
+
If the host `Activity` transitions into a non-interactive state (for example, `onPause`), the UI transaction will be scheduled to finish automatically (as soon as all of its child spans are finished).
274
+
275
+
Transactions are always bound to the `Scope` automatically if there's none set. Because of that, you can create spans using manual instrumentation, and those spans will be automatically associated with the running UI transaction.
276
+
277
+
```java
278
+
importjava.lang.Exception;
279
+
280
+
importio.sentry.ISpan;
281
+
importio.sentry.Sentry;
282
+
importio.sentry.SpanStatus;
283
+
284
+
void loadUserDataOnClick() {
285
+
ISpan span =Sentry.getSpan();
286
+
if (span !=null) {
287
+
ISpan innerSpan = span.startChild("loadUserData");
288
+
try {
289
+
// omitted code
290
+
} catch (Exception e) {
291
+
innerSpan.setThrowable(e);
292
+
innerSpan.setStatus(SpanStatus.NOT_FOUND);
293
+
throw e;
294
+
} finally {
295
+
innerSpan.finish();
296
+
}
297
+
}
298
+
}
299
+
```
300
+
301
+
```kotlin
302
+
importjava.lang.Exception
303
+
304
+
importio.sentry.Sentry
305
+
importio.sentry.SpanStatus
306
+
307
+
funloadUserDataOnClick() {
308
+
val span =Sentry.getSpan()
309
+
span?.let {
310
+
val innerSpan = it.startChild("displayUloadUserDataserData")
311
+
312
+
try {
313
+
// omitted code
314
+
} catch (e:Exception) {
315
+
innerSpan.throwable = e
316
+
innerSpan.status =SpanStatus.NOT_FOUND
317
+
throw e
318
+
} finally {
319
+
innerSpan.finish()
320
+
}
321
+
}
322
+
}
323
+
```
324
+
325
+
When the UI transaction is not finished yet, but the user makes a new interaction, the SDK automatically finishes the previous UI transaction. This is because only one transaction can be bound to the scope at a time. However, if the same view has been interacted with (for example, a `RecyclerView` was scrolled again within the `idleTimeout` window), the idle timer will be reset and the transaction duration will be extended with the `idleTimeout` value.
The idle time, measured in ms, to wait until a transaction will be automatically finished. The transaction will use the end timestamp of the last finished span as the endtime for the transaction.
389
+
390
+
The default is `3000`.
391
+
392
+
_(New in version 6.0.0)_
393
+
394
+
<Note>
395
+
396
+
This only affects [user interaction transactions](/platforms/android/performance/instrumentation/automatic-instrumentation/#user-interaction-instrumentation).
0 commit comments