Skip to content

Commit 1eb097c

Browse files
author
Emanuele Palazzetti
committed
[core] integrate instance config with global configurations
1 parent 1454e97 commit 1eb097c

File tree

5 files changed

+16
-18
lines changed

5 files changed

+16
-18
lines changed

ddtrace/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from .pin import Pin
33
from .span import Span
44
from .tracer import Tracer
5-
from .configuration import Config
5+
from .settings import Config
66

77
__version__ = '0.11.1'
88

ddtrace/config.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

ddtrace/configuration.py renamed to ddtrace/settings.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@ def __getattr__(self, name):
2626
'Integration "{}" is not registered in this configuration'.format(e.message)
2727
)
2828

29+
def get_from(self, obj):
30+
"""Retrieves the configuration for the given object.
31+
Any object that has an attached `Pin` must have a configuration
32+
and if a wrong object is given, an empty `dict` is returned
33+
for safety reasons.
34+
"""
35+
pin = Pin.get_from(obj)
36+
if pin is None:
37+
return {}
38+
39+
return pin._config
40+
2941
def _add(self, integration, settings):
3042
"""Internal API that registers an integration with given default
3143
settings.

tests/test_configuration.py renamed to tests/test_global_config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
from nose.tools import eq_, ok_, assert_raises
44

55
from ddtrace import config as global_config
6-
from ddtrace.configuration import Config, ConfigException
6+
from ddtrace.settings import Config, ConfigException
77

88

9-
class ConfigTestCase(TestCase):
9+
class GlobalConfigTestCase(TestCase):
1010
"""Test the `Configuration` class that stores integration settings"""
1111
def setUp(self):
1212
self.config = Config()

tests/test_config.py renamed to tests/test_instance_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from ddtrace.pin import Pin
77

88

9-
class ConfigTestCase(TestCase):
9+
class InstanceConfigTestCase(TestCase):
1010
"""TestCase for the Configuration API that is used to define
1111
global settings and for each `Pin` instance.
1212
"""

0 commit comments

Comments
 (0)