Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Recorder.configure: don't overwrite plugins unless specified #38

Merged
merged 2 commits into from
Mar 19, 2018

Conversation

MarSoft
Copy link
Contributor

@MarSoft MarSoft commented Mar 14, 2018

With most options, Recorder.configure() doesn't touch the value if corresponding option is not passed.
But with plugins option behaviour is different: it is updated every time you call configure.
So this code won't work correctly:

xray_recorder.configure(plugins=('EC2Plugin', 'ECS'))
...
xray_recorder.configure(context=MyContext())  # this resets plugins

This patch will fix that behaviour: now in order to explicitly reset plugins, you will need to pass an empty tuple to configure;
if plugins is None then plugin list won't be changed.

With most options, Recorder.configure() doesn't touch the value if corresponding option is not passed.
But with `plugins` option behaviour is different: it is updated every time you call `configure`.
So this code won't work correctly:

    xray_recorder.configure(plugins=('EC2Plugin', 'ECS'))
    ...
    xray_recorder.configure(context=MyContext())  # this resets plugins

This patch will fix that behaviour: now in order to explicitly reset plugins, you will need to pass an empty tuple to `configure`;
if `plugins is None` then plugin list won't be changed.
@haotianw465
Copy link
Contributor

haotianw465 commented Mar 15, 2018

What do you think of doing this:

         if plugins:
             plugin_modules = get_plugin_modules(plugins)
             for module in plugin_modules:
                 module.initialize()
             self._plugins = plugin_modules

@MarSoft
Copy link
Contributor Author

MarSoft commented Mar 16, 2018

This approach makes it impossible to remove previously added plugins.

@MarSoft
Copy link
Contributor Author

MarSoft commented Mar 16, 2018

I.e. it will only change plugins list if at least one plugin is specified, with no option to pass empty list (which will be just ignored). Hence I added "is None" check.

@haotianw465
Copy link
Contributor

OK make sense.

@haotianw465
Copy link
Contributor

Could you also add a line on CHANGELOG under "unreleased" section.

@MarSoft
Copy link
Contributor Author

MarSoft commented Mar 18, 2018

Done. Shall I squash it to the previous commit?

Copy link
Contributor

@haotianw465 haotianw465 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't worry I can do it.

@haotianw465 haotianw465 merged commit c354f6a into aws:master Mar 19, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants