elastic / elastic/apm-agent-python

The set_custom_context API attaches contexts only to transactions

Đang mở
#1,124 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
agent-python feature
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ả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu trong elasticapm/traces.py, quanh dòng 848, và so sánh tài liệu API set_custom_context với đối số custom của capture_exception. Theo dõi cách context được gắn vào các transaction được lấy mẫu so với các error, sau đó xác định hành vi nhất quán nhỏ nhất để làm phong phú error mà không ảnh hưởng đến việc lấy mẫu transaction; hoàn thành khi hành vi API được tài liệu hóa và đường dẫn làm phong phú error khớp nhau.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
observability
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.