Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Commit 26fd836

Browse files
authored
Refactor config_integration (#548)
Avoid having to manually update config_integrations when adding/removing extension packages. Remove hard-coded SUPPORTED_INTEGRATIONS.
1 parent 16d3ab3 commit 26fd836

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

opencensus/trace/config_integration.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@
1717

1818
log = logging.getLogger(__name__)
1919

20-
SUPPORTED_INTEGRATIONS = ['httplib', 'mysql', 'postgresql', 'pymysql',
21-
'requests', 'sqlalchemy', 'google_cloud_clientlibs',
22-
'threading', 'pymongo']
23-
24-
PATH_PREFIX = 'opencensus.ext'
25-
2620

2721
def trace_integrations(integrations, tracer=None):
2822
"""Enable tracing on the selected integrations.
@@ -32,17 +26,13 @@ def trace_integrations(integrations, tracer=None):
3226
integrated = []
3327

3428
for item in integrations:
29+
module_name = 'opencensus.ext.{}.trace'.format(item)
3530
try:
36-
path_to_module = '{}.{}.trace'.format(PATH_PREFIX, item)
37-
module = importlib.import_module(path_to_module)
31+
module = importlib.import_module(module_name)
3832
module.trace_integration(tracer=tracer)
3933
integrated.append(item)
4034
except Exception as e:
41-
log.warning(
42-
'Failed to integrate module: {}, supported integrations are {}'
43-
.format(
44-
item,
45-
', '.join(str(x) for x in SUPPORTED_INTEGRATIONS)))
35+
log.warning('Failed to integrate module: {}'.format(module_name))
4636
log.warning('{}'.format(e))
4737

4838
return integrated

0 commit comments

Comments
 (0)