Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ endif::[]

* Differentiate Lambda URLs from API Gateway in AWS Lambda integration {pull}#1609[#1609]
* Restrict the size of Django request bodies to prevent APM Server rejection {pull}#1610[#1610]
* Restrict length of `exception.message` for exceptions captured by the agent {pull}#1619[#1619]



Expand Down
4 changes: 3 additions & 1 deletion elasticapm/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import sys

from elasticapm.conf.constants import EXCEPTION_CHAIN_MAX_DEPTH
from elasticapm.utils import varmap
from elasticapm.utils import encoding, varmap
from elasticapm.utils.encoding import keyword_field, shorten, to_unicode
from elasticapm.utils.logging import get_logger
from elasticapm.utils.stacks import get_culprit, get_stack_info, iter_traceback_frames
Expand Down Expand Up @@ -133,6 +133,8 @@ def capture(client, exc_info=None, **kwargs):
else:
message = "%s: %s" % (exc_type, to_unicode(exc_value)) if exc_value else str(exc_type)

message = encoding.long_field(message)

data = {
"id": "%032x" % random.getrandbits(128),
"culprit": keyword_field(culprit),
Expand Down
10 changes: 10 additions & 0 deletions tests/client/exception_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,3 +397,13 @@ def generate_uuid():
generate_uuid()
except Exception:
elasticapm_client.capture_exception()


def test_long_message(elasticapm_client):
try:
raise Exception("t" * 1000000)
except:
elasticapm_client.capture_exception()

exception = elasticapm_client.events[ERROR][0]
assert exception["exception"]["message"] == f'Exception: {"t"*9988}{"…"}'