Skip to content

RUM-13468: Add totalRam, logicalCpuCount and isLowRam to DeviceInfo#3024

Open
marco-saia-datadog wants to merge 1 commit intodevelopfrom
marcosaia/RUM-12199/new-device-capability-metrics
Open

RUM-13468: Add totalRam, logicalCpuCount and isLowRam to DeviceInfo#3024
marco-saia-datadog wants to merge 1 commit intodevelopfrom
marcosaia/RUM-12199/new-device-capability-metrics

Conversation

@marco-saia-datadog
Copy link
Member

@marco-saia-datadog marco-saia-datadog commented Nov 24, 2025

What does this PR do?

Adds new attributes to the Device Info:

  • totalRam: The total RAM in megabytes
  • processorCount: Number of logical CPU cores available for scheduling on the device at runtime, as reported by the operating system.
  • isLowRam: Whether the device is considered a low RAM device (from ActivityManager.isLowRamDevice)

Additional Notes

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

@marco-saia-datadog marco-saia-datadog force-pushed the marcosaia/RUM-12199/new-device-capability-metrics branch 2 times, most recently from a5339c4 to 899ef0f Compare November 24, 2025 15:07
@marco-saia-datadog marco-saia-datadog changed the title [FEAT] Added 'totalRam', 'processorCount' and 'isLowRamDevice' to DeviceInfo RUM-12199: Added 'totalRam', 'processorCount' and 'isLowRamDevice' to DeviceInfo Nov 24, 2025
@marco-saia-datadog marco-saia-datadog changed the title RUM-12199: Added 'totalRam', 'processorCount' and 'isLowRamDevice' to DeviceInfo RUM-12199: Add 'totalRam', 'processorCount' and 'isLowRamDevice' to DeviceInfo Nov 24, 2025
@marco-saia-datadog marco-saia-datadog changed the title RUM-12199: Add 'totalRam', 'processorCount' and 'isLowRamDevice' to DeviceInfo RUM-12199: Add totalRam, processorCount and isLowRamDevice to DeviceInfo Nov 24, 2025
@marco-saia-datadog marco-saia-datadog force-pushed the marcosaia/RUM-12199/new-device-capability-metrics branch 2 times, most recently from 65945bf to 55a5484 Compare November 24, 2025 15:35
@datadog-official

This comment has been minimized.

@codecov-commenter
Copy link

codecov-commenter commented Nov 24, 2025

Codecov Report

❌ Patch coverage is 78.65169% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.99%. Comparing base (39d8b4a) to head (a95c0f6).
⚠️ Report is 4 commits behind head on develop.

Files with missing lines Patch % Lines
...core/internal/system/DefaultAndroidInfoProvider.kt 18.75% 13 Missing ⚠️
...tadog/android/core/internal/NoOpContextProvider.kt 0.00% 3 Missing ⚠️
...id/core/internal/system/NoOpAndroidInfoProvider.kt 0.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3024      +/-   ##
===========================================
+ Coverage    70.96%   70.99%   +0.03%     
===========================================
  Files          912      912              
  Lines        33548    33628      +80     
  Branches      5640     5640              
===========================================
+ Hits         23804    23871      +67     
- Misses        8173     8184      +11     
- Partials      1571     1573       +2     
Files with missing lines Coverage Δ
...tlin/com/datadog/android/api/context/DeviceInfo.kt 100.00% <100.00%> (ø)
...og/android/core/internal/DatadogContextProvider.kt 97.92% <100.00%> (+0.14%) ⬆️
...android/log/internal/domain/DatadogLogGenerator.kt 97.71% <100.00%> (+0.03%) ⬆️
...g/android/rum/internal/DatadogLateCrashReporter.kt 90.64% <100.00%> (+1.64%) ⬆️
...ndroid/rum/internal/domain/scope/RumActionScope.kt 96.65% <100.00%> (+0.05%) ⬆️
...roid/rum/internal/domain/scope/RumResourceScope.kt 91.50% <100.00%> (+1.01%) ⬆️
.../android/rum/internal/domain/scope/RumViewScope.kt 93.88% <100.00%> (-0.87%) ⬇️
...ernal/domain/scope/RumVitalAppLaunchEventHelper.kt 89.00% <100.00%> (+0.34%) ⬆️
...ndroid/telemetry/internal/TelemetryEventHandler.kt 88.10% <100.00%> (-0.18%) ⬇️
...trace/internal/domain/event/BaseSpanEventMapper.kt 72.73% <100.00%> (+9.31%) ⬆️
... and 3 more

... and 29 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@marco-saia-datadog marco-saia-datadog force-pushed the marcosaia/RUM-12199/new-device-capability-metrics branch from 55a5484 to c356214 Compare December 1, 2025 11:56
@marco-saia-datadog marco-saia-datadog force-pushed the marcosaia/RUM-12199/new-device-capability-metrics branch from c356214 to a4e01bd Compare December 11, 2025 11:57
@marco-saia-datadog marco-saia-datadog marked this pull request as ready for review December 11, 2025 13:19
@marco-saia-datadog marco-saia-datadog requested a review from a team as a code owner December 11, 2025 13:19
@marco-saia-datadog marco-saia-datadog changed the title RUM-12199: Add totalRam, processorCount and isLowRamDevice to DeviceInfo RUM-13468: Add totalRam, processorCount and isLowRamDevice to DeviceInfo Dec 18, 2025
@marco-saia-datadog marco-saia-datadog force-pushed the marcosaia/RUM-12199/new-device-capability-metrics branch from a4e01bd to 5235618 Compare January 13, 2026 15:15
@marco-saia-datadog marco-saia-datadog changed the title RUM-13468: Add totalRam, processorCount and isLowRamDevice to DeviceInfo RUM-13468: Add totalRam, logicalCpuCount and isLowRam to DeviceInfo Jan 16, 2026
@marco-saia-datadog marco-saia-datadog force-pushed the marcosaia/RUM-12199/new-device-capability-metrics branch 3 times, most recently from 84cc489 to 0d87288 Compare January 22, 2026 13:50
@marco-saia-datadog marco-saia-datadog force-pushed the marcosaia/RUM-12199/new-device-capability-metrics branch 5 times, most recently from b08d16b to 1163614 Compare February 2, 2026 14:45
@marco-saia-datadog marco-saia-datadog force-pushed the marcosaia/RUM-12199/new-device-capability-metrics branch from 1163614 to a95c0f6 Compare February 2, 2026 16:04
Copy link
Member

@0xnm 0xnm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just some minor cleanup is needed.

Comment on lines +41 to +42
val totalRam: Int?,
val isLowRam: Boolean?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe these two are nullable because the API we use to get this info may not return the data?

UPD: I see, it is due to the exception handling.

- "android.content.Context.getSharedPreferences(kotlin.String?, kotlin.Int)"
- "android.content.Context.getSystemService(kotlin.String)"
- "android.content.Context.getSharedPreferences(kotlin.String?, kotlin.Int)"
- "android.content.Context.getSystemService(java.lang.Class)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

neat! we indeed can use it now since min API is 23.

)
@MockitoSettings(strictness = Strictness.LENIENT)
@ForgeConfiguration(Configurator::class)
@ForgeConfiguration(value = Configurator::class, seed = 0xd1285cd0106L)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a debugging leftover and should be removed

assertThat(actual.device)
.usingRecursiveComparison()
.ignoringFields("batteryLevel", "brightnessLevel")
.ignoringFields("batteryLevel", "brightnessLevel", "totalRam", "logicalCpuCount")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Afaik this was to avoid losing precision in the floating point values between serialization/deserialization roundtrip, so it is not needed for the integer values. Same for other deserialized assertions below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants