in elasticapm/instrumentation/packages/pymemcache.py [0:0]
def call(self, module, method, wrapped, instance, args, kwargs):
name = self.get_wrapped_name(wrapped, instance, method)
# Since HashClient uses Client/PooledClient for the actual calls, we
# don't need to get address/port info for that class
address, port = None, None
if getattr(instance, "server", None):
if isinstance(instance.server, (list, tuple)):
# Address/port are a tuple
address, port = instance.server
else:
# Server is a UNIX domain socket
address = instance.server
destination = {
"address": address,
"port": port,
}
if "PooledClient" in name:
# PooledClient calls out to Client for the "work", but only once,
# so we don't care about the "duplicate" spans from Client in that
# case
with capture_span(
name,
span_type="cache",
span_subtype="memcached",
span_action="query",
extra={"destination": destination},
leaf=True,
):
return wrapped(*args, **kwargs)
else:
with capture_span(
name,
span_type="cache",
span_subtype="memcached",
span_action="query",
extra={"destination": destination},
leaf=True,
):
return wrapped(*args, **kwargs)