Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(internal): remove time functions from compat module #10861

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

vitor-de-araujo
Copy link
Contributor

@vitor-de-araujo vitor-de-araujo commented Sep 30, 2024

This PR removes 4 time-related functions from ddtrace.internal.compat that existed for compatibility with Python < 3.7, and replaces all uses with the corresponding functions from the builtin time module: time_ns, monotonic, monotonic_ns, process_time_ns.

The original motivation for this was noticing that the fallback code for time_ns had the wrong multiplier [edit: it's not actually wrong, just written in a weird way], and then checking that we don't really need these functions anymore, as we only support Python >= 3.7.

Checklist

  • PR author has checked that all the criteria below are met
  • The PR description includes an overview of the change
  • The PR description articulates the motivation for the change
  • The change includes tests OR the PR description describes a testing strategy
  • The PR description notes risks associated with the change, if any
  • Newly-added code is easy to change
  • The change follows the library release note guidelines
  • The change includes or references documentation updates if necessary
  • Backport labels are set (if applicable)

Reviewer Checklist

  • Reviewer has checked that all the criteria below are met
  • Title is accurate
  • All changes are related to the pull request's stated goal
  • Avoids breaking API changes
  • Testing strategy adequately addresses listed risks
  • Newly-added code is easy to change
  • Release note makes sense to a user of the library
  • If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment
  • Backport labels are set in a manner that is consistent with the release branch maintenance policy

Copy link
Contributor

github-actions bot commented Sep 30, 2024

CODEOWNERS have been resolved as:

benchmarks/rate_limiter/scenario.py                                     @DataDog/apm-core-python
ddtrace/_trace/span.py                                                  @DataDog/apm-sdk-api-python
ddtrace/contrib/internal/botocore/services/kinesis.py                   @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/internal/kafka/patch.py                                 @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/debugging/_debugger.py                                          @DataDog/debugger-python
ddtrace/internal/compat.py                                              @DataDog/python-guild @DataDog/apm-core-python
ddtrace/internal/opentelemetry/span.py                                  @DataDog/apm-sdk-api-python
ddtrace/internal/rate_limiter.py                                        @DataDog/apm-core-python
ddtrace/internal/utils/time.py                                          @DataDog/apm-core-python
ddtrace/profiling/collector/_lock.py                                    @DataDog/profiling-python
ddtrace/profiling/collector/memalloc.py                                 @DataDog/profiling-python
ddtrace/profiling/collector/stack.pyx                                   @DataDog/profiling-python
ddtrace/profiling/scheduler.py                                          @DataDog/profiling-python
tests/debugging/mocking.py                                              @DataDog/debugger-python
tests/integration/test_sampling.py                                      @DataDog/apm-core-python
tests/profiling/exporter/test_http.py                                   @DataDog/profiling-python
tests/profiling/test_accuracy.py                                        @DataDog/profiling-python
tests/profiling/test_scheduler.py                                       @DataDog/profiling-python
tests/submod/stuff.py                                                   @DataDog/apm-core-python
tests/tracer/test_rate_limiter.py                                       @DataDog/apm-sdk-api-python

@vitor-de-araujo vitor-de-araujo changed the title Remove time functions from compat module chore(internal): remove time functions from compat module Sep 30, 2024
@datadog-dd-trace-py-rkomorn
Copy link

datadog-dd-trace-py-rkomorn bot commented Sep 30, 2024

Datadog Report

Branch report: vitor-de-araujo/remove-compat-time-ns
Commit report: 7800477
Test service: dd-trace-py

✅ 0 Failed, 592 Passed, 694 Skipped, 18m 58.37s Total duration (18m 11.86s time saved)

@pr-commenter
Copy link

pr-commenter bot commented Sep 30, 2024

Benchmarks

Benchmark execution time: 2024-10-01 08:27:12

Comparing candidate commit 7800477 in PR branch vitor-de-araujo/remove-compat-time-ns with baseline commit 1c13106 in branch main.

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

@@ -1,9 +1,9 @@
from datetime import datetime
import time
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Maybe? Not sure if this was intentional for some reason

Suggested change
import time
from time import monotonic

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's what I meant to ask here, if we should change all instances of monotonic or just that one, but I think the question was misunderstood. Should I go ahead and change all?

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.

4 participants