mirror of
https://github.com/jlengrand/bugsink.git
synced 2026-03-10 15:48:31 +00:00
handled: searchable as a tag
also: don't display this in the detail view when the value isn't actually in the data
This commit is contained in:
@@ -481,11 +481,18 @@ def issue_event_details(request, issue, event_pk=None, digest_order=None, nav=No
|
||||
# transaction_info.source avoid information overload; sentry doesn't bother showing this in the UI either
|
||||
("event_id", event.event_id),
|
||||
("bugsink_internal_id", event.id),
|
||||
]
|
||||
|
||||
# grepping on [private-]samples (admittedly: not a very rich set) has shown: when there's multiple values for
|
||||
# mechanism, they're always identical. We just pick the 'main' (best guess) if this ever turns out to be false.
|
||||
# sentry repeats this info throughout the chains in the trace, btw, but I don't want to pollute my UI so much.
|
||||
("handled", get_path(get_main_exception(parsed_data), "mechanism", "handled")),
|
||||
if get_path(get_main_exception(parsed_data), "mechanism", "handled") is not None:
|
||||
key_info += [
|
||||
# grepping on [private-]samples (admittedly: not a very rich set) has shown: when there's multiple values
|
||||
# for mechanism, they're always identical. We just pick the 'main' (best guess) if this ever turns out to be
|
||||
# false. sentry repeats this info throughout the chains in the trace, btw, but I don't want to pollute my
|
||||
# UI so much.
|
||||
("handled", get_path(get_main_exception(parsed_data), "mechanism", "handled")),
|
||||
]
|
||||
|
||||
key_info += [
|
||||
("mechanism", get_path(get_main_exception(parsed_data), "mechanism", "type")),
|
||||
|
||||
("issue_id", issue.id),
|
||||
|
||||
@@ -23,6 +23,10 @@ class DeduceTagsTestCase(RegularTestCase):
|
||||
"server_name": "server",
|
||||
"release": "1.0",
|
||||
"environment": "prod",
|
||||
"mechanism": {
|
||||
"type": "exception",
|
||||
"handled": False,
|
||||
},
|
||||
"transaction": "main",
|
||||
"contexts": {
|
||||
"trace": {
|
||||
@@ -43,6 +47,7 @@ class DeduceTagsTestCase(RegularTestCase):
|
||||
"server_name": "server",
|
||||
"release": "1.0",
|
||||
"environment": "prod",
|
||||
"handled": "false",
|
||||
"transaction": "main",
|
||||
"trace": "1f2d3e4f5a6b5c8df9e0a1b2c3d4e5f",
|
||||
"trace.span": "9a8b7c6d5e4f3a2c",
|
||||
|
||||
@@ -1,14 +1,24 @@
|
||||
from events.ua_stuff import get_contexts_enriched_with_ua
|
||||
from sentry.utils.safe import get_path
|
||||
|
||||
from issues.utils import get_main_exception
|
||||
|
||||
|
||||
EVENT_DATA_CONVERSION_TABLE = {
|
||||
# NOTE that "level" is not included here; Sentry puts this front and center, and although we may give it _some_
|
||||
# place in the UI, Bugsink's take is that "level: Error" in an Error Tracker is an open door/waste of space.
|
||||
"server_name": "server_name",
|
||||
"release": "release",
|
||||
"environment": "environment",
|
||||
"transaction": "transaction",
|
||||
# "level" is not included here; Sentry puts this front and center for the tags; although we give it a non-prominent
|
||||
# place in the UI for the event-detail, Bugsink's take is that "level: Error" in an Error Tracker is not useful
|
||||
# enough to warrant display-as-tag, nor even is it a searchable term.
|
||||
# "level": ("level",),
|
||||
|
||||
"server_name": ("server_name",),
|
||||
"release": ("release",),
|
||||
"environment": ("environment",),
|
||||
"transaction": ("transaction",),
|
||||
}
|
||||
|
||||
|
||||
MAIN_EXCEPTION_CONVERSION_TABLE = {
|
||||
"handled": ("mechanism", "handled"),
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +52,12 @@ def deduce_user_tag(contexts):
|
||||
return None
|
||||
|
||||
|
||||
def _convert_non_strings(value):
|
||||
if isinstance(value, bool):
|
||||
return str(value).lower()
|
||||
return value
|
||||
|
||||
|
||||
def deduce_tags(event_data):
|
||||
"""
|
||||
Deduce tags for `event_data`. Used as an "opportunistic" (generic) way to implement counting and searching. Although
|
||||
@@ -54,9 +70,20 @@ def deduce_tags(event_data):
|
||||
tags = event_data.get('tags', {})
|
||||
|
||||
for tag_key, lookup_path in EVENT_DATA_CONVERSION_TABLE.items():
|
||||
value = get_path(event_data, lookup_path)
|
||||
value = get_path(event_data, *lookup_path)
|
||||
|
||||
# NOTE: we don't have some kind of "defaulting" mechanism here; if the value is None / non-existent, we simply
|
||||
# don't add the tag.
|
||||
if value not in [None, ""]:
|
||||
tags[tag_key] = value
|
||||
tags[tag_key] = _convert_non_strings(value)
|
||||
|
||||
# deduce from main exception
|
||||
main_exception = get_main_exception(event_data)
|
||||
for tag_key, lookup_path in MAIN_EXCEPTION_CONVERSION_TABLE.items():
|
||||
value = get_path(main_exception, *lookup_path)
|
||||
|
||||
if value not in [None, ""]:
|
||||
tags[tag_key] = _convert_non_strings(value)
|
||||
|
||||
# deduce from contexts
|
||||
contexts = get_contexts_enriched_with_ua(event_data)
|
||||
@@ -64,7 +91,7 @@ def deduce_tags(event_data):
|
||||
for tag_key, path in CONTEXT_CONVERSION_TABLE.items():
|
||||
value = get_path(contexts, *path)
|
||||
if value not in [None, ""]:
|
||||
tags[tag_key] = value
|
||||
tags[tag_key] = _convert_non_strings(value)
|
||||
|
||||
if "trace" in tags and "trace.span" in tags:
|
||||
tags["trace.ctx"] = f"{tags['trace']}.{tags['trace.span']}"
|
||||
|
||||
Reference in New Issue
Block a user