Skip to content

Commit 12791bc

Browse files
authored
chore(tracing): remove runtime import of asm config in Pin.enabled (#13578)
We need to avoid this as much as possible. I couldn't find the circular import/reason why it was done that way. This _should_ have a benefit for performance, but local benchmarks showed it mostly flat, so maybe only a micro optimization, but still good behavior. ## 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 - [ ] 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)
1 parent e9972f9 commit 12791bc

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

ddtrace/_trace/pin.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import wrapt
77

88
import ddtrace
9+
from ddtrace.settings.asm import config as asm_config
910

1011
from ..internal.logger import get_logger
1112

@@ -174,12 +175,8 @@ def _override(
174175
pin._tracer = tracer
175176
pin.onto(obj)
176177

177-
def enabled(self):
178-
# type: () -> bool
178+
def enabled(self) -> bool:
179179
"""Return true if this pin's tracer is enabled."""
180-
# inline to avoid circular imports
181-
from ddtrace.settings.asm import config as asm_config
182-
183180
return bool(self.tracer) and (self.tracer.enabled or asm_config._apm_opt_out)
184181

185182
def onto(self, obj, send=True):

0 commit comments

Comments
 (0)