Skip to content

Avoid method redefinition warning when replacing time providers#4613

Merged
p-datadog merged 6 commits into
masterfrom
avoid-method-redef
May 5, 2025
Merged

Avoid method redefinition warning when replacing time providers#4613
p-datadog merged 6 commits into
masterfrom
avoid-method-redef

Conversation

@p-datadog

@p-datadog p-datadog commented Apr 28, 2025

Copy link
Copy Markdown
Member

What does this PR do?

Undefines existing time provider methods before redefining them to avoid the following warnings:

/home/w/apps/dd-trace-rb/lib/datadog/core/utils/time.rb:46: warning: method redefined; discarding old get_time
/home/w/apps/dd-trace-rb/lib/datadog/core/configuration/settings.rb:725: warning: previous definition of get_time was here

Motivation:
Warning-clean library

Change log entry
Yes: avoid Ruby warnings when providing a custom time provider

Additional Notes:
The method removal is guarded in case customers remove the methods themselves to avoid the warning

How to test the change?
Tested manually by running the relevant examples:

rspec spec/datadog/core/configuration/settings_spec.rb spec/datadog/tracing/configuration/settings_spec.rb

@p-datadog
p-datadog requested a review from a team as a code owner April 28, 2025 18:32
@github-actions github-actions Bot added the core Involves Datadog core libraries label Apr 28, 2025
@codecov-commenter

codecov-commenter commented Apr 28, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.75%. Comparing base (01fa6c8) to head (a6ef7d0).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4613      +/-   ##
==========================================
- Coverage   97.75%   97.75%   -0.01%     
==========================================
  Files        1417     1417              
  Lines       86327    86332       +5     
  Branches     4349     4349              
==========================================
+ Hits        84393    84395       +2     
- Misses       1934     1937       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Apr 28, 2025

Copy link
Copy Markdown
Contributor

Datadog Report

Branch report: avoid-method-redef
Commit report: a6ef7d0
Test service: dd-trace-rb

✅ 0 Failed, 21260 Passed, 1373 Skipped, 3m 42.49s Total Time

@pr-commenter

pr-commenter Bot commented Apr 28, 2025

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2025-05-05 15:10:26

Comparing candidate commit a6ef7d0 in PR branch avoid-method-redef with baseline commit 01fa6c8 in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 31 metrics, 2 unstable metrics.

Comment thread lib/datadog/core/utils/time.rb

@Strech Strech 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.

👍🏼

@p-datadog
p-datadog merged commit 245e4a9 into master May 5, 2025
@p-datadog
p-datadog deleted the avoid-method-redef branch May 5, 2025 16:18
@github-actions github-actions Bot added this to the 2.16.0 milestone May 5, 2025
@Strech Strech mentioned this pull request May 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Involves Datadog core libraries

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants