Skip to content

Conversation

@kikoveiga
Copy link
Contributor

@kikoveiga kikoveiga commented Nov 18, 2025

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
Copy link

codecov-commenter commented Nov 18, 2025

Codecov Report

❌ Patch coverage is 88.75740% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.33%. Comparing base (4f0f65a) to head (fa401f1).

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.40%   71.33%   -0.07%     
===========================================
  Files          881      881              
  Lines        32388    32431      +43     
  Branches      5462     5464       +2     
===========================================
+ Hits         23126    23133       +7     
- Misses        7727     7750      +23     
- Partials      1535     1548      +13     
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.00% <100.00%> (+0.33%) ⬆️
...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 44 more

... and 30 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
Copy link

datadog-official bot commented Nov 20, 2025

🎯 Code Coverage
Patch Coverage: 81.36%
Overall Coverage: 66.39% (-0.01%)

View detailed report

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: fa401f1 | 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
Copy link
Contributor

@aleksandr-gringauz aleksandr-gringauz left a comment

Choose a reason for hiding this comment

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

Nice work!

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.

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
@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 2 times, most recently from fca49de to 75df8d5 Compare December 23, 2025 15:47
@kikoveiga kikoveiga force-pushed the kikoveiga/RUM-10363/use-time-provider branch 2 times, most recently from a9e08d8 to bf2f14c Compare December 23, 2025 16:43
@kikoveiga kikoveiga force-pushed the kikoveiga/RUM-10363/use-time-provider branch from bf2f14c to fa401f1 Compare December 23, 2025 17:54
@kikoveiga kikoveiga requested a review from 0xnm December 23, 2025 21:49
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