Skip to content

refactor: configuration instance [recreated] #12991

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

Merged
merged 5 commits into from
Apr 3, 2025
Merged

Conversation

erikayasuda
Copy link
Contributor

@erikayasuda erikayasuda commented Mar 31, 2025

Recreating #12970 because we needed to revert PRs that were accidentally merged prematurely due to required status checks getting deleted.

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

P403n1x87 and others added 2 commits March 31, 2025 12:32
We move the creation of the configuration instance in the module where
the class itself is defined. We then update the imports to grab a
reference directly from the settings module, instead of the root module
ddtrace. This way we remove a substantial number of circular import
paths within the library.
Copy link
Contributor

github-actions bot commented Mar 31, 2025

CODEOWNERS have been resolved as:

ddtrace/__init__.py                                                     @DataDog/apm-core-python
ddtrace/_monkey.py                                                      @DataDog/apm-core-python
ddtrace/_trace/processor/__init__.py                                    @DataDog/apm-sdk-api-python
ddtrace/_trace/provider.py                                              @DataDog/apm-sdk-api-python
ddtrace/_trace/sampler.py                                               @DataDog/apm-sdk-api-python
ddtrace/_trace/span.py                                                  @DataDog/apm-sdk-api-python
ddtrace/_trace/tracer.py                                                @DataDog/apm-sdk-api-python
ddtrace/contrib/internal/subprocess/patch.py                            @DataDog/asm-python
ddtrace/contrib/internal/trace_utils.py                                 @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/internal/core/event_hub.py                                      @DataDog/apm-core-python
ddtrace/internal/datastreams/processor.py                               @DataDog/apm-core-python
ddtrace/internal/processor/stats.py                                     @DataDog/apm-core-python
ddtrace/internal/sampling.py                                            @DataDog/apm-sdk-api-python
ddtrace/internal/schema/processor.py                                    @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/propagation/http.py                                             @DataDog/apm-sdk-api-python
ddtrace/settings/_config.py                                             @DataDog/apm-core-python
ddtrace/settings/asm.py                                                 @DataDog/asm-python

Copy link
Contributor

github-actions bot commented Mar 31, 2025

Bootstrap import analysis

Comparison of import times between this PR and base.

Summary

The average import time from this PR is: 230 ± 5 ms.

The average import time from base is: 234 ± 5 ms.

The import time difference between this PR and base is: -4.1 ± 0.2 ms.

Import time breakdown

The following import paths have appeared:

ddtrace.auto 2.443 ms (1.06%)
ddtrace 2.443 ms (1.06%)
ddtrace.settings._config 2.443 ms (1.06%)
ddtrace.internal._file_queue 2.443 ms (1.06%)
secrets 2.136 ms (0.93%)
hmac 1.896 ms (0.82%)
_hashlib 0.905 ms (0.39%)
hashlib 0.667 ms (0.29%)
_blake2 0.313 ms (0.14%)

The following import paths have disappeared:

ddtrace.auto 2.446 ms (1.06%)
ddtrace 2.446 ms (1.06%)
ddtrace.internal._file_queue 2.446 ms (1.06%)
secrets 2.133 ms (0.93%)
hmac 1.903 ms (0.83%)
_hashlib 0.916 ms (0.40%)
hashlib 0.667 ms (0.29%)
_blake2 0.318 ms (0.14%)

The following import paths have grown:

ddtrace.auto 3.359 ms (1.46%)
ddtrace 3.359 ms (1.46%)
ddtrace.settings._config 3.205 ms (1.39%)
ddtrace.trace 0.154 ms (0.07%)
ddtrace._trace.filters 0.081 ms (0.04%)
ddtrace._trace.processor 0.081 ms (0.04%)
ddtrace._trace.sampler 0.081 ms (0.04%)
ddtrace._trace.span 0.081 ms (0.04%)
ddtrace._trace.tracer 0.073 ms (0.03%)
ddtrace.settings.peer_service 0.073 ms (0.03%)

The following import paths have shrunk:

ddtrace.auto 5.584 ms (2.42%)
ddtrace 4.188 ms (1.82%)
ddtrace.trace 0.215 ms (0.09%)
ddtrace._trace.filters 0.125 ms (0.05%)
ddtrace._trace.processor 0.125 ms (0.05%)
ddtrace._trace.sampler 0.125 ms (0.05%)
ddtrace._trace.tracer 0.089 ms (0.04%)
ddtrace.internal.schema.processor 0.089 ms (0.04%)
ddtrace._monkey 0.040 ms (0.02%)
ddtrace.bootstrap.sitecustomize 1.396 ms (0.61%)
ddtrace.bootstrap.preload 1.396 ms (0.61%)
ddtrace.internal.products 1.396 ms (0.61%)
ddtrace.internal.remoteconfig.client 0.660 ms (0.29%)

@erikayasuda erikayasuda added the changelog/no-changelog A changelog entry is not required for this PR. label Mar 31, 2025
@pr-commenter
Copy link

pr-commenter bot commented Mar 31, 2025

Benchmarks

Benchmark execution time: 2025-04-03 09:59:43

Comparing candidate commit 1f1d95e in PR branch refactor/config-instance with baseline commit fe197c9 in branch main.

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

@erikayasuda erikayasuda marked this pull request as ready for review March 31, 2025 21:25
@erikayasuda erikayasuda requested review from a team as code owners March 31, 2025 21:25
@P403n1x87 P403n1x87 enabled auto-merge (squash) April 1, 2025 12:52
@P403n1x87 P403n1x87 self-assigned this Apr 1, 2025
Copy link
Contributor

github-actions bot commented Apr 3, 2025

CODEOWNERS have been resolved as:

ddtrace/__init__.py                                                     @DataDog/apm-core-python
ddtrace/_monkey.py                                                      @DataDog/apm-core-python
ddtrace/_trace/processor/__init__.py                                    @DataDog/apm-sdk-api-python
ddtrace/_trace/provider.py                                              @DataDog/apm-sdk-api-python
ddtrace/_trace/sampler.py                                               @DataDog/apm-sdk-api-python
ddtrace/_trace/span.py                                                  @DataDog/apm-sdk-api-python
ddtrace/_trace/tracer.py                                                @DataDog/apm-sdk-api-python
ddtrace/contrib/internal/subprocess/patch.py                            @DataDog/asm-python
ddtrace/contrib/internal/trace_utils.py                                 @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/internal/core/event_hub.py                                      @DataDog/apm-core-python
ddtrace/internal/datastreams/processor.py                               @DataDog/apm-core-python
ddtrace/internal/processor/stats.py                                     @DataDog/apm-core-python
ddtrace/internal/sampling.py                                            @DataDog/apm-sdk-api-python
ddtrace/internal/schema/processor.py                                    @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/propagation/http.py                                             @DataDog/apm-sdk-api-python
ddtrace/settings/_config.py                                             @DataDog/apm-core-python
ddtrace/settings/asm.py                                                 @DataDog/asm-python

@erikayasuda erikayasuda requested a review from mabdinur April 3, 2025 14:54
@P403n1x87 P403n1x87 merged commit 3ec5b05 into main Apr 3, 2025
678 of 680 checks passed
@P403n1x87 P403n1x87 deleted the refactor/config-instance branch April 3, 2025 15:31
chojomok pushed a commit that referenced this pull request Apr 7, 2025
Recreating #12970 because we
needed to revert PRs that were accidentally merged prematurely due to
required status checks getting deleted.

## Checklist
- [x] 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](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist
- [x] 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](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
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](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)

Co-authored-by: Gabriele N. Tornetta <[email protected]>
Co-authored-by: Gabriele N. Tornetta <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog/no-changelog A changelog entry is not required for this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants