elastic / elastic/apm-agent-python

Issues with aioredis instrumentation

Open
#1,157 1 comment 0 reactions 0 assignees View on GitHub
agent-python
Dominant language
Python
Stars
431
Forks
239
Avg merge
5d 10h
Merged PRs (30d)
7

Description

**Describe the bug**: ...

aioredis instrumentation doesn't work with elastic-apm==6.2.2. The APM dashboard is not able to show it as dependency or in traces. I am using aioredis==1.2.0

**Environment (please complete the following information)**
- OS: [e.g. Linux] - MacOs Catalina
- Python version: 3.7.2
- Framework and version [e.g. Django 2.1]: aiohttp
- APM Server version: 7.13
- Agent version: 6.2.2

**Additional context**
I have added a couple of comments in the following merged PR: https://github.com/elastic/apm-agent-python/pull/1129

I made some changes to the following class to make it work:

Existing class:

```
class RedisConnectionInstrumentation(AbstractInstrumentedModule):
name = "aioredis"

instrument_list = (("aioredis.connection", "RedisConnection.execute"),
("aioredis.pool", "ConnectionsPool.execute_pubsub"))

def call(self, module, method, wrapped, instance, args, kwargs):
span = execution_context.get_span()
if span and span.subtype == "aioredis":
span.context["destination"] = _get_destination_info(instance)
return wrapped(*args, **kwargs)
```

Updated class:

```
class RedisConnectionInstrumentation(AbstractInstrumentedModule):
name = "aioredis"

instrument_list = (("aioredis.connection", "RedisConnection.execute"),
("aioredis.pool", "ConnectionsPool.execute_pubsub"))

async def call(self, module, method, wrapped, instance, args, kwargs):
span = execution_context.get_span()
wrapped_name = self.get_wrapped_name(wrapped, instance, method)
if span and span.subtype == "aioredis":
span.context["destination"] = _get_destination_info(instance)
with async_capture_span(
wrapped_name, span_type="db", span_subtype="redis", span_action="query", leaf=True
):
return await wrapped(*args, **kwargs)
```

Also, span is coming as None here so it would never add the destination information to the span, hence it won;t appear in dependency.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.