Fix transaction truncation
This commit is contained in:
1 parent
c98cf64e9e
commit
7831a4d34e
3 files changed
+10
-2
No files matched your search
@@ -67,6 +67,12 @@ class IssueEventIngestTestCase(EventIngestTestCase):
|
||||
).exists()
|
||||
)
|
||||
|
||||
def test_transaction_truncation(self):
|
||||
data = self.get_json_data("events/test_data/py_hi_event.json")
|
||||
data["culprit"] = "x" * 201
|
||||
self.process_events(data)
|
||||
self.assertTrue(IssueEvent.objects.first())
|
||||
|
||||
def test_message_empty_param_list(self):
|
||||
self.process_events(
|
||||
[
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from django.utils.encoding import force_str
|
||||
|
||||
from sentry.constants import MAX_CULPRIT_LENGTH
|
||||
from sentry.culprit import generate_culprit
|
||||
from sentry.stacktraces.functions import get_function_name_for_frame
|
||||
from sentry.stacktraces.processing import get_crash_frame_from_event_data
|
||||
@@ -67,9 +68,10 @@ class ErrorEvent(BaseEvent):
|
||||
return "{}: {}".format(ty, str(metadata["value"]))
|
||||
|
||||
def get_location(self, data):
|
||||
return force_str(
|
||||
loc_string = force_str(
|
||||
data.get("culprit")
|
||||
or data.get("transaction")
|
||||
or generate_culprit(data)
|
||||
or ""
|
||||
)
|
||||
return truncatechars(loc_string, MAX_CULPRIT_LENGTH)
|
||||
@@ -3,7 +3,7 @@ from django.utils.encoding import smart_str
|
||||
|
||||
def truncatechars(value: str, chars=100):
|
||||
"""Truncate string and append …"""
|
||||
return (value[:chars] + "…") if len(value) > chars else value
|
||||
return (value[: chars - 3] + "…") if len(value) > chars else value
|
||||
|
||||
|
||||
def strip(value):
|
||||
|
||||
Reference in new issue
Block a user