elastic / elastic/apm-agent-python
Automatic instrumention for custom modules/classes
- Ngôn ngữ chính
- Python
- Star
- 431
- Fork
- 239
- Merge trung bình
- 5 ngày 10 giờ
- Pull request đã merge (30 ngày)
- 7
Mô tả
**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.
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu bằng việc xem xét decorator @capture_span hiện có và cách các ứng dụng Django được instrument. Làm rõ thiết kế để tự động bao phủ các module và class tùy chỉnh, bao gồm các thiết lập và loại trừ đối với file, module, thư mục, test và manage.py. Công việc được xem là hoàn tất khi phạm vi và hành vi cấu hình đã được thống nhất, đồng thời tính năng đã được xác thực cho các trường hợp sử dụng Django.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- django, python
- Lĩnh vực
- backend, observability
- Loại issue
- Tính năng
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 32/100