Skip to content

Commit 7d06be5

Browse files
author
Emanuele Palazzetti
committed
[core] improving Pin and configuration implementation
1 parent 1eb097c commit 7d06be5

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

ddtrace/pin.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def onto(self, obj, send=True):
119119
pin_name = _DD_PIN_PROXY_NAME if isinstance(obj, wrapt.ObjectProxy) else _DD_PIN_NAME
120120

121121
# set the target reference; any get_from, clones and retarget the new PIN
122-
self._target = obj
122+
self._target = id(obj)
123123
return setattr(obj, pin_name, self)
124124
except AttributeError:
125125
log.debug("can't pin onto object. skipping", exc_info=True)
@@ -130,6 +130,12 @@ def clone(self, service=None, app=None, app_type=None, tags=None, tracer=None):
130130
if not tags and self.tags:
131131
tags = self.tags.copy()
132132

133+
# we use a copy instead of a deepcopy because we expect configurations
134+
# to have only a root level dictionary without nested objects. Using
135+
# deepcopy introduces a big overhead:
136+
#
137+
# copy: 0.00654911994934082
138+
# deepcopy: 0.2787208557128906
133139
config = self._config.copy()
134140

135141
return Pin(

ddtrace/settings.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1+
import logging
2+
13
from copy import deepcopy
24

5+
from .pin import Pin
6+
7+
8+
log = logging.getLogger(__name__)
9+
310

411
class ConfigException(Exception):
512
"""Configuration exception when an integration that is not available
@@ -34,6 +41,7 @@ def get_from(self, obj):
3441
"""
3542
pin = Pin.get_from(obj)
3643
if pin is None:
44+
log.debug('No configuration found for %s', obj)
3745
return {}
3846

3947
return pin._config

0 commit comments

Comments
 (0)