Skip to content

Commit 3c8c662

Browse files
authored
Recorder.configure: don't overwrite plugins unless specified
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.
1 parent ab8cde7 commit 3c8c662

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

aws_xray_sdk/core/recorder.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ def configure(self, sampling=None, plugins=None,
7373
:param tuple plugins: plugins that add extra metadata to each segment.
7474
Currently available plugins are EC2Plugin, ECS plugin and
7575
ElasticBeanstalkPlugin.
76+
If you want to disable all previously enabled plugins,
77+
pass an empty tuple ``()``.
7678
:param str context_missing: recorder behavior when it tries to mutate
7779
a segment or add a subsegment but there is no active segment.
7880
RUNTIME_ERROR means the recorder will raise an exception.
@@ -117,12 +119,13 @@ def configure(self, sampling=None, plugins=None,
117119
if streaming_threshold:
118120
self.streaming_threshold = streaming_threshold
119121

120-
plugin_modules = None
121-
if plugins:
122-
plugin_modules = get_plugin_modules(plugins)
123-
for module in plugin_modules:
124-
module.initialize()
125-
self._plugins = plugin_modules
122+
if plugins is not None:
123+
plugin_modules = None
124+
if plugins:
125+
plugin_modules = get_plugin_modules(plugins)
126+
for module in plugin_modules:
127+
module.initialize()
128+
self._plugins = plugin_modules
126129

127130
def begin_segment(self, name=None, traceid=None,
128131
parent_id=None, sampling=None):

0 commit comments

Comments
 (0)