elastic / elastic/apm-agent-python

[Agent-Python] AsyncIO + ThreadPool Span Tracing

オープン
#1,324 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る
agent-python instrumentation
主要言語
Python
スター
431
フォーク
239
平均マージ
5日 10時間
マージ済み PR(30日)
7

説明

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

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

まず、報告された Python、Flask、agent のバージョンを使って、Flask エンドポイントの同期関数、asyncio ブロック、ThreadPoolExecutor のフローを再現します。capture_span と async_capture_span を #499 の回避策と比較し、span がリクエストだけでなく非同期処理とスレッド処理もカバーしていることを確認してください。この issue は、実装を完了と見なす前に、tracing のアプローチが確認されている必要があります。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
flask, python
領域
backend, observability-sre
issue の種類
バグ
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
28/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。