How do I increase the max length of captured Python parameters in Sentry?
Asked Answered
F

3

9

I'm using sentry-python==0.5.3 in a Django 1.11.6 project, and when I inspect a stacktrace's parameter list, I see some of the values are long enough to be cut off by a ... elipsis. I want to see the entire value.

How do I configure sentry-python to show the entire parameter value in the stacktrace?

Here's how I'm calling the init function in my Django config:

sentry_sdk.init(
    dsn="sentry dsn",
    integrations=[DjangoIntegration()],
    send_default_pii=True
)
Fimbriate answered 10/12, 2018 at 3:27 Comment(1)
github.com/getsentry/sentry-python/issues/377Polypeptide
F
3

I just found this in the sentry-sdk Python source code, which makes me think it's not yet possible to configure this in the new SDK.

# TODO: read max_length from config

https://github.com/getsentry/sentry-python/blob/9f15a4027615d40cfdb37375233bc903d3cc753e/sentry_sdk/utils.py#L626

Fimbriate answered 10/12, 2018 at 3:42 Comment(1)
To provide some context, there are some limits serverside that this code is supposed to avoid. I think we can totally add a config for this on the client (feel free to open an issue) but you have to be aware that your value still might be trimmed on the server. Probably not to as little as 512 chars though.Kumasi
C
15

I just found this in the sentry-sdk python source code: https://github.com/getsentry/sentry-python/blob/0.12.2/sentry_sdk/utils.py#L36

and indeed:

sentry_sdk.utils.MAX_STRING_LENGTH = 8192 # undocumented truncation length as of v0.12.2

after sentry_sdk.init works as expected (the sentry web client displays the entire error message instead of ... after the first 512 characters).

Note that, as @Markus Unterwaditzer mentions, sentry's server may still do some truncation, but I haven't encountered it with error messages ~5000 characters in length. Hopefully the stack trace and breadcrumbs get truncated before the error message itself.

Chlores answered 26/9, 2019 at 21:12 Comment(0)
F
3

I just found this in the sentry-sdk Python source code, which makes me think it's not yet possible to configure this in the new SDK.

# TODO: read max_length from config

https://github.com/getsentry/sentry-python/blob/9f15a4027615d40cfdb37375233bc903d3cc753e/sentry_sdk/utils.py#L626

Fimbriate answered 10/12, 2018 at 3:42 Comment(1)
To provide some context, there are some limits serverside that this code is supposed to avoid. I think we can totally add a config for this on the client (feel free to open an issue) but you have to be aware that your value still might be trimmed on the server. Probably not to as little as 512 chars though.Kumasi
S
0

In v2 sentry-sdk, we have a new option max_value_length. We can do

    sentry_sdk.init(
        max_value_length=8192,
    )

https://docs.sentry.io/platforms/python/configuration/options/#max-value-length

Silkstocking answered 6/9, 2024 at 23:29 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.