elastic / elastic/apm-agent-python
The set_custom_context API attaches contexts only to transactions
- 主要言語
- Python
- スター
- 431
- フォーク
- 239
- 平均マージ
- 5日 10時間
- マージ済み PR(30日)
- 7
説明
**Describe the bug**:
When using `set_custom_context` API, as per [documentation](https://www.elastic.co/guide/en/apm/agent/python/master/api.html#api-set-custom-context), the expectation is to be able to attach custom data to a `Transaction` or to an `Error`.
From the [code](https://github.com/elastic/apm-agent-python/blob/4d125e6f554a85b84085ddcf1fb783bc7228922c/elasticapm/traces.py#L848), it seems we apply the custom context only to `Transactions` which are sampled.
**Expected behavior**
The custom context should be attached to the `Error` too so that it will not be affected by sampling.
In any case, the request is to have an API to enrich errors without it being affected by sampling.
**Potential workaround**
If the objective is to enrich exceptions/errors, it is possible to use the `custom` named argument of `capture_exception` to enrich it. This information is attached to the `Error` and it will not be sampled.
**Environment**
- Python version: Python 2.7
- Framework and version: Django 1.11
- Agent version: 5.10.1
コントリビューションガイド
調査の方向性
elasticapm/traces.py の848行目付近から始め、set_custom_context API のドキュメントと capture_exception の custom 引数を比較してください。サンプリングされたトランザクションとエラーそれぞれにコンテキストがどのように付加されるかを追跡し、トランザクションのサンプリングを変更せずにエラーをエンリッチする、最小限で一貫した挙動を定義してください。完了条件は、ドキュメント化された API の挙動とエラーのエンリッチメント経路が一致することです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- observability
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100