elastic / elastic/apm-agent-python

Automatic instrumention for custom modules/classes

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

説明

**Is your feature request related to a problem? Please describe.**
Currently using APM with Django apps and `@capture_span` has been incredibly helpful in finding bottlenecks and optimizing performance. However when new functionality is added, its tedious for the developer to remember to apply the decorator everywhere.

While [explicit is better than implicit](https://www.python.org/dev/peps/pep-0020/), explicit also increases the likelihood that it's missed or forgotten, and at times (of which this may be one) implicit can be preferred when something useful comes for free in future development.

**Describe the solution you'd like**
An option to auto-instrument custom written modules and classes with `@capture_span` in a Django application would be a killer feature. Ideally this could just be a settings flag or included module. Additional useful configuration would be ignoring certain files, modules, or directories; for example for ignoring test code or unimportant-to-trace framework files like `manage.py` in Django.

**Describe alternatives you've considered**
We've looked into a couple different ways of solving this with code, such as programatically adding decorator to all [class functions](https://stackoverflow.com/questions/3467526/attaching-a-decorator-to-all-functions-within-a-class) or [module functions](https://stackoverflow.com/questions/38017401/patch-all-functions-in-module-with-decorator).

We've also considered using CI validation to validate on pull requests that the decorator was applied to new functionality, which would follow "explicit is better than implicit" more closely. This also might spawn a python module to check this, as experiments validating with a multi-line `grep` have been...hairy.

**Additional context**
As a final note, an argument could be made (although I'm sure someone will correct me) that monitoring is more a deployment concern than an application concern, and so more comprehensive automatic instrumentation without explicit references in source code could be appropriate.

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

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

調査の方向性

まず、既存の @capture_span デコレーターと、Django アプリケーションがどのように計装されているかを確認します。カスタムモジュールとクラスを自動的にカバレッジ対象にするための設計を明確にします。これには、ファイル、モジュール、ディレクトリ、テスト、manage.py に対する設定と除外が含まれます。スコープと設定の動作について合意し、Django のユースケースで機能を検証できた状態を完了とします。

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

評価

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

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

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