Skip to content

RUM-10363: Replace System static calls with TimeProvider#3011

Merged
kikoveiga merged 5 commits into
developfrom
kikoveiga/RUM-10363/use-time-provider
Jan 2, 2026
Merged

RUM-10363: Replace System static calls with TimeProvider#3011
kikoveiga merged 5 commits into
developfrom
kikoveiga/RUM-10363/use-time-provider

Conversation

@kikoveiga

@kikoveiga kikoveiga commented Nov 18, 2025

Copy link
Copy Markdown
Contributor

What does this PR do?

  • Replaces System.currentTimeMillis() and System.nanoTime() calls with TimeProvider interface calls.
  • Improves and optimizes some tests by replacing Thread.sleep calls with fake timestamps using a mockTimeProvider.

Motivation

  • Static calls are not mockable. Using an interface is better for injecting mock implementations and general testability.

Additional Notes

These are the results of running debug unit tests locally on develop and current branch, where there are noticeable time improvements.

image

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)

@kikoveiga kikoveiga self-assigned this Nov 18, 2025
@codecov-commenter

codecov-commenter commented Nov 18, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.26554% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.48%. Comparing base (f7fffa7) to head (733a513).
⚠️ Report is 851 commits behind head on develop.

Files with missing lines Patch % Lines
...adog/android/internal/profiler/DDExecutionTimer.kt 0.00% 3 Missing ⚠️
.../com/datadog/android/internal/time/TimeProvider.kt 0.00% 3 Missing ⚠️
...e/internal/thread/ObservableLinkedBlockingQueue.kt 50.00% 1 Missing and 1 partial ⚠️
...tadog/android/internal/profiler/GlobalBenchmark.kt 0.00% 2 Missing ⚠️
...tadog/android/internal/time/DefaultTimeProvider.kt 0.00% 2 Missing ⚠️
...dog/android/rum/resource/RumResourceInputStream.kt 75.00% 0 Missing and 2 partials ⚠️
...n/com/datadog/android/core/internal/CoreFeature.kt 87.50% 1 Missing ⚠️
.../android/core/internal/logger/SdkInternalLogger.kt 50.00% 0 Missing and 1 partial ⚠️
...roid/core/internal/thread/ThreadPoolExecutorExt.kt 50.00% 0 Missing and 1 partial ⚠️
...g/android/log/internal/logger/DatadogLogHandler.kt 50.00% 0 Missing and 1 partial ⚠️
... and 1 more
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3011      +/-   ##
===========================================
- Coverage    71.50%   71.48%   -0.01%     
===========================================
  Files          881      881              
  Lines        32413    32460      +47     
  Branches      5464     5466       +2     
===========================================
+ Hits         23174    23204      +30     
- Misses        7702     7712      +10     
- Partials      1537     1544       +7     
Files with missing lines Coverage Δ
.../com/datadog/android/api/feature/FeatureSdkCore.kt 33.33% <ø> (ø)
...n/com/datadog/android/core/internal/DatadogCore.kt 77.66% <100.00%> (+0.08%) ⬆️
...tadog/android/core/internal/NoOpInternalSdkCore.kt 8.91% <100.00%> (+2.79%) ⬆️
...in/com/datadog/android/core/internal/SdkFeature.kt 90.00% <100.00%> (+0.09%) ⬆️
...d/core/internal/data/upload/RotatingDnsResolver.kt 92.86% <100.00%> (+1.19%) ⬆️
...id/core/internal/metrics/BatchMetricsDispatcher.kt 94.59% <100.00%> (ø)
...oid/core/internal/metrics/MethodCalledTelemetry.kt 100.00% <100.00%> (ø)
...sistence/file/advanced/ConsentAwareFileMigrator.kt 82.98% <100.00%> (+1.58%) ⬆️
...rsistence/file/advanced/FeatureFileOrchestrator.kt 100.00% <100.00%> (ø)
...stence/file/advanced/MoveDataMigrationOperation.kt 100.00% <100.00%> (ø)
... and 46 more

... and 34 files with indirect coverage changes

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

@datadog-official

datadog-official Bot commented Nov 20, 2025

Copy link
Copy Markdown

🎯 Code Coverage
Patch Coverage: 82.16%
Overall Coverage: 66.45% (-0.03%)

View detailed report

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 733a513 | Docs | Datadog PR Page | Was this helpful? Give us feedback!

@kikoveiga
kikoveiga marked this pull request as ready for review December 9, 2025 17:19
@kikoveiga
kikoveiga requested a review from a team as a code owner December 9, 2025 17:19
@kikoveiga
kikoveiga force-pushed the kikoveiga/RUM-10363/use-time-provider branch 5 times, most recently from d4a2312 to 3715bec Compare December 12, 2025 12:14

@aleksandr-gringauz aleksandr-gringauz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice work!

Comment thread tools/benchmark/src/main/java/com/datadog/benchmark/DatadogVitalsMeter.kt Outdated

@0xnm 0xnm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I very briefly went through some files.

@kikoveiga
kikoveiga force-pushed the kikoveiga/RUM-10363/use-time-provider branch from 3715bec to 5153c40 Compare December 16, 2025 13:23
@kikoveiga
kikoveiga force-pushed the kikoveiga/RUM-10363/use-time-provider branch from 6c5ec4a to d6bd044 Compare December 17, 2025 12:43
Comment thread tools/unit/build.gradle.kts Outdated
@kikoveiga
kikoveiga force-pushed the kikoveiga/RUM-10363/use-time-provider branch 2 times, most recently from 54e7da2 to 5491a1b Compare December 22, 2025 17:38
@kikoveiga
kikoveiga force-pushed the kikoveiga/RUM-10363/use-time-provider branch 5 times, most recently from bf2f14c to fa401f1 Compare December 23, 2025 17:54
@kikoveiga
kikoveiga requested a review from 0xnm December 23, 2025 21:49
@kikoveiga
kikoveiga force-pushed the kikoveiga/RUM-10363/use-time-provider branch 2 times, most recently from 1f8d675 to 815615b Compare December 31, 2025 16:06
@kikoveiga
kikoveiga force-pushed the kikoveiga/RUM-10363/use-time-provider branch from 815615b to af30673 Compare December 31, 2025 16:10
0xnm
0xnm previously approved these changes Jan 2, 2026
@kikoveiga
kikoveiga force-pushed the kikoveiga/RUM-10363/use-time-provider branch from 01e1ea1 to 733a513 Compare January 2, 2026 14:03
@kikoveiga
kikoveiga merged commit 7eda91f into develop Jan 2, 2026
26 checks passed
@kikoveiga
kikoveiga deleted the kikoveiga/RUM-10363/use-time-provider branch January 2, 2026 16:34
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.

5 participants