Performance Telemetry

Capture native Android Java heap, native heap, RSS, FPS, battery, and custom metric telemetry.

Android performance telemetry records numeric samples on metric channels.

Built-In Channels

The native Android runtime can record:

  • Java heap
  • native heap
  • RSS
  • FPS through Android frame callbacks
  • battery level when enabled
  • app-defined channels and metric streams

Custom Metrics

import ai.ansight.Ansight
import ai.ansight.runtime.AnsightChannel
import ai.ansight.runtime.AnsightRuntime

Ansight.registerMetricChannel(
    AnsightChannel(
        id = 42,
        name = "Queue Depth",
        colorHex = "#FF9500",
        unit = "items",
        type = "queue",
    ),
)

AnsightRuntime.metric(17, channel = 42)

For sampled values:

import ai.ansight.runtime.AnsightMetricSampler
import ai.ansight.runtime.AnsightMetricStream

Ansight.registerMetricStream(
    AnsightMetricStream(
        channel = AnsightChannel(43, "Cache Items", unit = "items", type = "cache"),
        sampler = AnsightMetricSampler { cache.itemCount.toLong() },
    ),
)

Reserved channel ids include built-in memory channels, FPS, lifecycle, battery, and 255 unspecified.

Runtime Sampling

AnsightRuntime.captureBuiltInTelemetrySample()

Battery telemetry is opt-in:

val options = AnsightOptions.createBuilder()
    .withBatteryLevel()
    .build()