elastic / elastic/apm-agent-python

Issues with aioredis instrumentation

Offen
#1,157 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
agent-python
Vorherrschende Sprache
Python
Sterne
431
Forks
239
Ø Merge
5 T. 10 Std.
Gemergte PRs (30 T.)
7

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne damit, RedisConnectionInstrumentation und seine Einstiegspunkte aioredis.connection.RedisConnection.execute und aioredis.pool.ConnectionsPool.execute_pubsub zu finden, und reproduziere dann das Problem mit den aufgeführten Versionen von aioredis, elastic-apm, Python und aiohttp. Als abgeschlossen gilt die Aufgabe, wenn aioredis-Operationen Datenbank-Spans erzeugen, die als Abhängigkeiten und in Traces erscheinen, einschließlich der Zielinformationen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
observability-sre
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.