Skip to content

Commit bafedb3

Browse files
authored
update use of MetricKit in mobile instrumentation docs (#238)
1 parent 5f61724 commit bafedb3

4 files changed

Lines changed: 27 additions & 40 deletions

File tree

‎docs/instrument/mobile/android.md‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -285,15 +285,11 @@ at-most-once delivery).
285285
| Field | Type | Default | Description |
286286
|---|---|---|---|
287287
| `offlineBufferEnabled` | `Boolean` | `false` | Master toggle. Persist failed batches and replay them on next `initialize()` or connectivity change. |
288-
| `offlineMaxTraceItems` | `Int` | `0` | Accepted, not yet enforced. |
289-
| `offlineMaxMetricItems` | `Int` | `0` | Accepted, not yet enforced. |
290-
| `offlineMaxLogItems` | `Int` | `0` | Accepted, not yet enforced. |
291-
| `maxOfflineStorageMb` | `Int` | `5` | Accepted, not yet enforced. |
292-
293-
The four cap fields are part of the config surface but nothing reads
294-
them yet. When `offlineBufferEnabled` is on, the persisted queue is
295-
bounded by `maxQueueSize` and `maxExportBatchSize` — the same limits the
296-
in-memory path uses. Size the buffer with those.
288+
| `maxOfflineStorageMb` | `Int` | `5` | Cap on the on-disk offline buffer. Once it is exceeded, the oldest persisted batches are pruned first (FIFO). Only active when `offlineBufferEnabled` is on. |
289+
290+
When `offlineBufferEnabled` is on, the persisted queue is also bounded by
291+
`maxQueueSize` and `maxExportBatchSize` — the same limits the in-memory
292+
path uses.
297293

298294
### Diagnostics
299295

‎docs/instrument/mobile/hybrid.md‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ detects the native SDK and delegates to it, and both layers report under one
3737
| Export pipeline | Native | Flutter forwards spans, logs, and metrics over the bridge. Same-process, one exporter for both layers; different-process, one per process |
3838
| Breadcrumbs, user and session attributes | Shared | Set on either side, visible to both |
3939
| Native Android telemetry | `scout-android` | Screens, taps, HTTP, JVM and NDK crashes, ANR, jank, vitals. See [Android](./android.md) |
40-
| Native iOS telemetry | Bridge engine | Screens, KSCrash native crashes, app hangs, HTTP, jank, vitals. Taps, startup tracking, and MetricKit are off in bridge mode |
40+
| Native iOS telemetry | Bridge engine | Screens, KSCrash native crashes, app hangs, MetricKit diagnostics, HTTP, jank, vitals. Taps and startup tracking are off in bridge mode |
4141
| Flutter telemetry | `scout_flutter` | Screens, taps, HTTP, errors, and jank from the Flutter layer, forwarded to the native side. See [Flutter](./flutter.md) |
4242
| Crash de-duplication | Native | In hybrid mode `scout_flutter` drains and discards its own crash files, so a crash is reported once |
4343

@@ -341,16 +341,14 @@ func presentFlutter() {
341341

342342
:::note What bridge mode leaves out on iOS
343343
The engine `scout_flutter` starts for you covers sessions, screen views,
344-
KSCrash native crashes, app hangs, HTTP, jank, and vitals on the native side.
345-
Three things are off in bridge mode:
344+
KSCrash native crashes, app hangs, MetricKit `MXCrashDiagnostic` /
345+
`MXHangDiagnostic` diagnostics, HTTP, jank, and vitals on the native side.
346+
Two things are off in bridge mode:
346347

347348
- Tap tracking (`enableTapTracking` defaults to `false`).
348349
- Startup and cold-start tracking (`enableStartupTracking` defaults to `false`).
349-
- MetricKit diagnostics. `Scout.startBridge` does not subscribe
350-
`MetricKitSubscriber`, so `MXCrashDiagnostic` and `MXHangDiagnostic` reports
351-
never arrive. KSCrash still captures native crashes in-process.
352350

353-
To get all three, call `Scout.start(...)` yourself in
351+
To get both, call `Scout.start(...)` yourself in
354352
`application(_:didFinishLaunchingWithOptions:)` **before** `flutterEngine.run()`,
355353
using the same `serviceName` and `endpoint` as the Flutter config. The engine is
356354
a first-wins singleton: whichever of `Scout.start` and the plugin's
@@ -385,7 +383,7 @@ Calling `Scout.start` after Flutter has started has no effect. See
385383
| **`main()` throws on startup** before any telemetry appears | `ScoutFlutter.initialize` reaches the native side over a platform channel, which needs the binding | Call `WidgetsFlutterBinding.ensureInitialized()` as the first line of `main()`. |
386384
| **Flutter data lands but under a different `session.id`** than native (not unified) | Different-process only: `role` was set to `ScoutRole.OWNER`, so the `:flutter` process skipped the cross-process lookup and minted its own session | Leave `role` at its `ScoutRole.AUTO` default. Same-process is unaffected. |
387385
| **Native screens/events don't appear on Android** | The native SDK was never initialized | Call `Scout.initialize` in `Application.onCreate`. |
388-
| **No native taps, cold-start spans, or MetricKit reports on iOS** | Bridge mode leaves tap tracking, startup tracking, and the MetricKit subscriber off | Call `Scout.start(...)` in `application(_:didFinishLaunchingWithOptions:)` before `flutterEngine.run()`. Screens, KSCrash crashes, and hangs are already covered without it. |
386+
| **No native taps or cold-start spans on iOS** | Bridge mode leaves tap tracking and startup tracking off | Call `Scout.start(...)` in `application(_:didFinishLaunchingWithOptions:)` before `flutterEngine.run()`. Screens, KSCrash crashes, hangs, and MetricKit diagnostics are already covered without it. |
389387

390388
## FAQ
391389

‎docs/instrument/mobile/ios.md‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -285,15 +285,11 @@ at-most-once delivery).
285285
| Parameter | Type | Default | Description |
286286
|---|---|---|---|
287287
| `offlineBufferEnabled` | `Bool` | `false` | Master toggle. Persist failed batches and replay them on the next launch. |
288-
| `offlineMaxTraceItems` | `Int` | `0` | Accepted, not yet enforced. |
289-
| `offlineMaxMetricItems` | `Int` | `0` | Accepted, not yet enforced. |
290-
| `offlineMaxLogItems` | `Int` | `0` | Accepted, not yet enforced. |
291-
| `maxOfflineStorageMb` | `Int` | `5` | Accepted, not yet enforced. |
292-
293-
The four cap parameters are part of the config surface but nothing reads
294-
them yet. When `offlineBufferEnabled` is on, the persisted queue is
295-
bounded by `maxQueueSize` and `maxExportBatchSize` — the same limits the
296-
in-memory path uses. Size the buffer with those.
288+
| `maxOfflineStorageMb` | `Int` | `5` | Cap on the on-disk offline buffer. Once it is exceeded, the oldest persisted batches are pruned first (FIFO). Only active when `offlineBufferEnabled` is on. |
289+
290+
When `offlineBufferEnabled` is on, the persisted queue is also bounded by
291+
`maxQueueSize` and `maxExportBatchSize` — the same limits the in-memory
292+
path uses.
297293

298294
### Diagnostics
299295

‎docs/instrument/mobile/kotlin-multiplatform.md‎

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@ capabilities** documented for each platform, driven from common code:
5252
set: Activity/Compose screens, taps, JVM + NDK crashes,
5353
`ApplicationExitInfo`, ANR, jank, startup, lifecycle, HTTP.
5454
- **iOS** — the [scout-ios](/instrument/mobile/ios) set: screens, taps,
55-
KSCrash native crashes, app hangs, jank, startup, lifecycle, HTTP. One
56-
exception: MetricKit is not subscribed on the KMP path (see the
57-
[FAQ](#faq)).
55+
KSCrash native crashes, app hangs, jank, startup, lifecycle, HTTP, and
56+
MetricKit `MXCrashDiagnostic` / `MXHangDiagnostic` diagnostics.
5857

5958
Every signal flows through the shared `scout-core` engine — the same
6059
sessions, sampling, batching, and OTLP export on both platforms. Each
@@ -271,11 +270,11 @@ instrumentation defaults to **on**; metric collection defaults to
271270
### Offline buffer
272271

273272
Disabled by default (strict at-most-once). `offlineBufferEnabled`
274-
(`false`) is the master toggle. The cap fields `offlineMaxTraceItems` /
275-
`offlineMaxMetricItems` / `offlineMaxLogItems` (`0`) and
276-
`maxOfflineStorageMb` (`5`) are part of the config surface but nothing
277-
reads them yet — when the buffer is on, the persisted queue is bounded
278-
by `maxQueueSize` and `maxExportBatchSize` instead.
273+
(`false`) is the master toggle. When the buffer is on,
274+
`maxOfflineStorageMb` (`5`) caps the on-disk buffer — once the cap is
275+
exceeded the oldest persisted batches are pruned first (FIFO) — and the
276+
persisted queue is additionally bounded by `maxQueueSize` and
277+
`maxExportBatchSize`.
279278

280279
### Diagnostics
281280

@@ -371,7 +370,6 @@ status to the platform console.
371370
| Crashes not appearing | They drain on the *next* launch on both platforms. Relaunch, then check the collector. |
372371
| Telemetry hard to distinguish from native SDK data | KMP exports carry a `scout.kmp.version` resource attribute — filter on it. |
373372
| No telemetry at all | Set `debugLogging = true` to print export attempts and their HTTP status, then confirm the endpoint is reachable from the device. Remember the default `sessionSampleRate` is **1%**. |
374-
| No MetricKit diagnostics on iOS | Expected. The KMP path does not install the MetricKit subscriber — see the FAQ below. |
375373

376374
## Performance considerations
377375

@@ -409,11 +407,10 @@ transitively at the versions listed under
409407

410408
No. `scout-kmp` calls the Kotlin engine (`ScoutEngine`) directly rather
411409
than the Swift `Scout.start(...)` entry point. KSCrash still installs,
412-
and ANR detection still runs — but from the Kotlin watchdog, gated by
413-
`enableAnrTracking`, instead of the Swift `AppHangWatchdog`. The
414-
practical difference is that **MetricKit is not subscribed on the KMP
415-
path**, so Apple's asynchronous `MXCrashDiagnostic` / `MXHangDiagnostic`
416-
payloads are not collected. Everything else in the
410+
ANR detection still runs — from the Kotlin watchdog, gated by
411+
`enableAnrTracking`, instead of the Swift `AppHangWatchdog` — and the
412+
engine subscribes to MetricKit, so Apple's asynchronous
413+
`MXCrashDiagnostic` / `MXHangDiagnostic` payloads are collected. The full
417414
[iOS](/instrument/mobile/ios) capability table applies.
418415

419416
**How do I track screens in a Compose Multiplatform app?**

0 commit comments

Comments
 (0)