Skip to content

Attach device condition context as structured attributes on perf spans #6340

Description

@antonis

Performance spans (app start, TTFD) currently carry no device condition context. When a slow startup is reported, there's no way to determine if it was caused by device throttling, low battery, or poor network conditions without manually correlating breadcrumbs.

Attaching the current device state as structured attributes on app start and TTFD spans would enable:

  • Filtering: "show slow startups where thermal state was critical"
  • Aggregation: "average cold start by network type"
  • Debugging: "this startup was slow because the device was thermally throttled"

Proposed attributes

Attribute iOS Source Android Source
device.thermal_state ProcessInfo.thermalState PowerManager.getCurrentThermalStatus() (API 29+)
device.battery.level UIDevice.batteryLevel BatteryManager.getIntProperty(BATTERY_PROPERTY_CAPACITY)
device.battery.charging UIDevice.batteryState BatteryManager sticky broadcast
device.low_power_mode ProcessInfo.isLowPowerModeEnabled PowerManager.isPowerSaveMode()
device.network.type NWPathMonitor / SCNetworkReachability ConnectivityManager.getActiveNetwork()
device.memory.available os_proc_available_memory() ActivityManager.getMemoryInfo()

Implementation

Native side (required): React Native core does NOT expose thermal state, battery level, low power mode, or network type. The Sentry native SDKs collect some of this at event time (deviceContextIntegration) but don't expose it for on-demand querying from JS.

New native bridge methods needed on both iOS and Android to snapshot device state on demand. Recommended: a single fetchDeviceConditions() method returning all values at once.

JS side: Call the native bridge method when app start / TTFD spans end, and set the returned values as span attributes.

Notes

  • Builds on completed #6099 / #6100 which bridged device-state breadcrumbs to JS. This is different — breadcrumbs report state changes over time, attributes report the current state at span end time.
  • Related: #4256 (connection type with cellular tech) is open but blocked on native SDK work.
  • Attribute names should align with conventions used by other Sentry SDKs. Coordinate with native SDK teams on naming.
  • All values are non-PII.

Scope

RN native (iOS + Android) + JS. New bridge methods on both platforms + JS integration to snapshot and attach at span end.

Metadata

Metadata

Assignees

No one assigned
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions