getsentry / getsentry/sentry-python

Append to Context/User

Đang mở
#933 4 bình luận 1 reaction 1 người được giao Được @sl0thentr0py nhận Xem trên GitHub
Discussion Improvement Python
Ngôn ngữ chính
Python
Star
2.2k
Fork
669
Merge trung bình
1 ngày 1 giờ
Pull request đã merge (30 ngày)
213

Mô tả

Use case:

1. get a user id when the request is initially parsed (eg. from an `Authorization` header), and call `scope.set_user({'http-username': 'bob'})`
2. later during request processing, get some more user information (say, email), and do `scope.set_user({'email': 'test@example.com'})`. Lets assume the request/headers aren't available at that point to re-retrieve `http-username`.
3. the later call **replaces** existing data in the scope (ie: the event ends up with only `{'email': 'test@example.com'}`)
4. same applies to other context sections (via `scope.set_context('section', {'some': 'value'})`)

AFAICT there isn't even a way to get the current user/contexts _out_ again in order to manually merge them except via internals (`scope._user`/`scope._contexts['a_section']`). The framework integrations all seem to append to the user data, but that seems to happen much later in the processing.

Would it be worth exposing getter properties/methods, add `scope.merge_*()` methods (which call `dict.update()`), add `merge=True|False` parameters to `set_user()` & `set_context()`, or something else equivalent?

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

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

Đánh giá

Issue này chưa được đánh giá.

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.