| 1 |
import importlib |
| 2 |
from ..exceptions.exceptions import MissingPluginNames |
| 3 |
|
| 4 |
module_prefix = 'aws_xray_sdk.core.plugins.' |
| 5 |
|
| 6 |
PLUGIN_MAPPING = { |
| 7 |
'elasticbeanstalkplugin': 'elasticbeanstalk_plugin', |
| 8 |
'ec2plugin': 'ec2_plugin', |
| 9 |
'ecsplugin': 'ecs_plugin' |
| 10 |
} |
| 11 |
|
| 12 |
|
| 13 |
def get_plugin_modules(plugins): |
| 14 |
""" |
| 15 |
Get plugin modules from input strings |
| 16 |
:param tuple plugins: a tuple of plugin names in str |
| 17 |
""" |
| 18 |
if not plugins: |
| 19 |
raise MissingPluginNames("input plugin names are required") |
| 20 |
|
| 21 |
modules = [] |
| 22 |
|
| 23 |
for plugin in plugins: |
| 24 |
short_name = PLUGIN_MAPPING.get(plugin.lower(), plugin.lower()) |
| 25 |
full_path = '%s%s' % (module_prefix, short_name) |
| 26 |
modules.append(importlib.import_module(full_path)) |
| 27 |
|
| 28 |
return tuple(modules) |