feat: Add breadcrumb hints#49
Merged
Merged
Conversation
Contributor
|
@untitaker I made an experiment on the plane where i changed add_breadcrumb to this: def add_breadcrumb(self, *args, **kwargs):
"""Adds a breadcrumb."""
client, scope = self._stack[-1]
if client is None:
logger.info("Dropped breadcrumb because no client bound")
return
if len(args) == 2:
crumb, hint = args
elif len(args) == 1:
crumb = args[0] or {}
hint = kwargs.pop("hint", None)
crumb.update(kwargs)
elif kwargs:
hint = kwargs.pop("hint", None)
crumb = kwargs
if crumb is None:
return
if crumb.get("timestamp") is None:
crumb["timestamp"] = datetime.utcnow()
if crumb.get("type") is None:
crumb["type"] = "default"
original_crumb = crumb
if client.options["before_breadcrumb"] is not None:
crumb = client.options["before_breadcrumb"](crumb, hint)
if crumb is not None:
scope._breadcrumbs.append(crumb)
else:
logger.info("before breadcrumb dropped breadcrumb (%s)", original_crumb)
while len(scope._breadcrumbs) >= client.options["max_breadcrumbs"]:
scope._breadcrumbs.popleft()That makes it less weird i think |
Member
Author
|
@mitsuhiko I'd like to somehow stop parsing args/kwargs, not sure how yet. Is this PR urgent? I'd like to think about it for some more |
Contributor
|
Not urgent |
markstory
reviewed
Sep 4, 2018
Member
Author
|
It's IMO wrong to call this function with something that can't be coerced
into a dict. My personal opinion is that the error message of dict() is
good enough in such cases
…On Tue, Sep 4, 2018, 16:11 Mark Story ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In sentry_sdk/hub.py
<#49 (comment)>
:
> @@ -161,6 +161,12 @@ def add_breadcrumb(self, *args, **kwargs):
logger.info("Dropped breadcrumb because no client bound")
return
+ hint = kwargs.pop("hint", None)
+ if not hint:
+ hint = {}
+ else:
+ hint = dict(hint)
Do you need to catch errors here for when the argument cannot be converted
into a dict?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#49 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAzHxd8msKvehgUStzCWmFoejpPpJA_Qks5uXonsgaJpZM4WYgBn>
.
|
Member
Author
|
@mitsuhiko Any opinions about: Idk which cases I am changing by this. |
Contributor
|
Might work? I guess at least. Seems fine by me. |
Contributor
|
Maybe we wrap |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I wonder if we could just put the hint on the breadcrumb itself and pop it
before sending? I am unhappy that the hint argument for before_breadcrumb is
now mandatory.