Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ddtrace/contrib/internal/pylibmc/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(self, client=None, service=memcached.SERVICE, tracer=None, *args, *
if not isinstance(client, _Client):
# We are in the patched situation, just pass down all arguments to the pylibmc.Client
# Note that, in that case, client isn't a real client (just the first argument)
client = _Client(client, *args, **kwargs)
client = _Client(kwargs.get("servers", client), **{k: v for k, v in kwargs.items() if k != "servers"})
else:
log.warning(
"TracedClient instantiation is deprecated and will be remove "
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
fixes:
- |
pylibmc: fixes an issue where using ``Client(server=[url])`` would throw the error ``__init__() got multiple values for argument 'servers'``
30 changes: 30 additions & 0 deletions tests/contrib/pylibmc/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,36 @@ def test_patch_unpatch(self):
assert spans, spans
assert len(spans) == 1

def test_client_with_servers_option(self):
"""
A test to make sure we support using `servers`, ie: with pylibmc.Client(servers=[url])
"""
url = "%s:%s" % (cfg["host"], cfg["port"])

patch()
client = pylibmc.Client(servers=[url])
assert client.addresses[0] is url
Pin.get_from(client)._clone(service=self.TEST_SERVICE, tracer=self.tracer).onto(client)
client.set("a", 1)
spans = self.pop_spans()
assert spans, spans
assert len(spans) == 1

def test_client_without_servers_option(self):
"""
A test to make sure we support the most basic use case of calling pylibmc.Client([url])
"""
url = "%s:%s" % (cfg["host"], cfg["port"])

patch()
client = pylibmc.Client([url])
assert client.addresses[0] is url
Pin.get_from(client)._clone(service=self.TEST_SERVICE, tracer=self.tracer).onto(client)
client.set("a", 1)
spans = self.pop_spans()
assert spans, spans
assert len(spans) == 1


class TestPylibmcPatchSchematization(TestPylibmcPatchDefault):
@TracerTestCase.run_in_subprocess(env_overrides=dict(DD_SERVICE="mysvc", DD_TRACE_SPAN_ATTRIBUTE_SCHEMA="v0"))
Expand Down
Loading