DataDog / datadog-ci-rb

Ruby library for Datadog test visibility
https://docs.datadoghq.com/continuous_integration/tests/ruby
Other
8 stars 4 forks source link

[NO-TICKET] automatically trace with correct time even when time is stubbed by timecop #185

Closed anmarchenko closed 4 months ago

anmarchenko commented 5 months ago

What does this PR do? timecop is a popular gem that is used to mock time in tests. It works by replacing Time.now method and aliasing the original as now_without_mock_time.

This creates issues with tests tracing as reported spans has invalid time and thus are being skipped or reported with wrong timestamps.

It is possible to setup time_now_provider in settings: we can do this automatically when activating CI mode so that no manual work from user's side is needed.

Motivation We received multiple customer support issues related to invalid start_time.

How to test the change? Unit tests are provided (with timecop dependency).

anmarchenko commented 5 months ago

Fun fact: it broke my tests that use Timecop as well! this means it works

codecov-commenter commented 4 months ago

Codecov Report

Attention: Patch coverage is 97.05882% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 98.93%. Comparing base (cbf442b) to head (4fa4efb).

Files Patch % Lines
lib/datadog/ci/configuration/components.rb 83.33% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #185 +/- ## ========================================== - Coverage 98.94% 98.93% -0.01% ========================================== Files 220 221 +1 Lines 10009 10034 +25 Branches 464 466 +2 ========================================== + Hits 9903 9927 +24 - Misses 106 107 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.