Make <no transaction> explicit;

and more moving-around-of-code in preparation for our next step
This commit is contained in:
Klaas van Schelven
2024-04-08 15:03:02 +02:00
parent cb75d318af
commit 729a4c7ea1
5 changed files with 80 additions and 89 deletions

View File

@@ -1,20 +0,0 @@
from sentry.utils.safe import get_path
from sentry.utils.strings import strip
from django.template.defaultfilters import truncatechars
class DefaultEvent:
"""The DefaultEvent is the Event for which there is no exception set. Given the implementation of `get_title`, I'd
actually say that this is basically the LogMessageEvent.
"""
def get_exception_type_and_value(self, data):
message = strip(
get_path(data, "logentry", "message")
or get_path(data, "logentry", "formatted")
)
if message:
return "Log Message", truncatechars(message.splitlines()[0], 100)
return "Log Message", "<no log message>"

View File

@@ -1,42 +0,0 @@
from sentry.stacktraces.functions import get_function_name_for_frame
from sentry.stacktraces.processing import get_crash_frame_from_event_data
from sentry.utils.safe import get_path, trim
def get_crash_location(data):
frame = get_crash_frame_from_event_data(
data,
frame_filter=lambda x: x.get("function") not in (None, "<redacted>", "<unknown>"),
)
if frame is not None:
func = get_function_name_for_frame(frame, data.get("platform"))
return frame.get("filename") or frame.get("abs_path"), func
return None, None
class ErrorEvent:
def get_exception_type_and_value(self, data):
if isinstance(data.get("exception"), list):
if len(data["exception"]) == 0:
return "<unknown>", ""
exception = get_path(data, "exception", "values", -1)
if not exception:
return "<unknown>", ""
value = trim(get_path(exception, "value", default=""), 1024)
# From the sentry docs:
# > An optional flag indicating that this error is synthetic. Synthetic errors are errors that carry little
# > meaning by themselves.
# If this flag is set, we ignored the Exception's type and used the function name instead (if available).
if get_path(exception, "mechanism", "synthetic"):
_, function = get_crash_location(data)
if function:
return function, ""
return "<unknown>", ""
type_ = trim(get_path(exception, "type", default="Error"), 128)
return type_, value