elastic / elastic/apm-agent-python

Issues with aioredis instrumentation

Aperta
#1,157 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
agent-python
Lingua principale
Python
Stelle
431
Fork
239
Merge medio
5g 10h
PR unite (30g)
7

Descrizione

**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.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia individuando RedisConnectionInstrumentation e i suoi punti di ingresso aioredis.connection.RedisConnection.execute e aioredis.pool.ConnectionsPool.execute_pubsub, quindi riproduci il problema con le versioni indicate di aioredis, elastic-apm, Python e aiohttp. Il lavoro è completato quando le operazioni aioredis producono span di database che compaiono come dipendenze e nelle tracce, comprese le informazioni sulla destinazione.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
observability-sre
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.