elastic / elastic/apm-agent-python

[Agent-Python] AsyncIO + ThreadPool Span Tracing

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

Beschreibung

**Describe the bug**:

Current setup: A flask endpoint that summons a sync function running asyncio code block and a threadpool executor that dovetails on the results of the asyncio code block

Looking for a way to monitor the function execution via the instrumentation of code running in those several threads.

- Both `@elasticapm.capture_span()` and `async_capture_span` were not able to trace the function execution as desired.
- Implemented the workaround suggested in #499 but did not work in my case.

Any advice/directions on this would be of great help. TIA.

**Environment (please complete the following information)**
- OS:
System Version: **macOS 10.14.6 (18G6020)**
Kernel Version: **Darwin 18.7.0**
- Python version: **3.8.0**
- Framework and version: **Flask 1.1.4**
- APM Server version: **7.6.2**
- Agent version: **6.4.0**

**Additional context**
Attaching a blueprint of the function block that gets triggered on hitting the flask request endpoint.

![image](https://user-images.githubusercontent.com/43657587/133158788-aeba0928-2e9e-457c-aabc-73fe80ad8884.png)

Essentially a bulk indexer job that posts to ES /_bulk endpoint post various data pre-processing.

On the APM front, only the request call/response duration is being captured by the agent:

![image](https://user-images.githubusercontent.com/43657587/133160023-52763544-78a2-4cb5-84db-a9be89653d42.png)

Any advice/directions on this would be of great help. TIA.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne damit, den synchronen Funktionsaufruf, den asyncio-Block und den ThreadPoolExecutor-Ablauf des Flask-Endpunkts mit den angegebenen Python-, Flask- und agent-Versionen zu reproduzieren. Vergleiche capture_span und async_capture_span mit dem Workaround aus #499 und überprüfe, ob Spans die asynchrone und Thread-Arbeit abdecken und nicht nur die Anfrage; das Issue benötigt einen bestätigten Tracing-Ansatz, bevor die Implementierung als abgeschlossen betrachtet werden kann.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
flask, python
Bereich
backend, observability-sre
Issue-Typ
Bug
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
28/100

Neue Issues direkt in Ihr Postfach

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