Skip to content

Respect with_locals setting #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 25, 2022
Merged

Respect with_locals setting #74

merged 1 commit into from
Aug 25, 2022

Conversation

alxwrd
Copy link
Contributor

@alxwrd alxwrd commented Aug 4, 2022

Hi!

This is a patch to use the with_locals setting from the Sentry client when creating an event.

with_locals is a setting you can enable when initialising the Sentry SDK (

sentry_sdk.init(
    with_locals=False,
    ...
)

) that can turn off local varibales being displayed with each stackframe.

event_from_exception uses it's own "client_options" which is used when creating the frames.

@alxwrd
Copy link
Contributor Author

alxwrd commented Aug 9, 2022

Current work around

import functools

import sentry_sdk
import structlog
import structlog_sentry

structlog_sentry.event_from_exception = functools.partial(
    structlog_sentry.event_from_exception,
    client_options={
        "with_locals": sentry_sdk.Hub.current.client.options.get("with_locals")
    },
)

structlog.configure(
    processors=[structlog_sentry.SentryProcessor],
)

@paveldedik
Copy link
Collaborator

Hi @alxwrd Thank you for the PR, could you please rebase your branch onto master? There are going to be some changes (you will definitely need to update tests).

For all changes see #79

@alxwrd
Copy link
Contributor Author

alxwrd commented Aug 19, 2022

hi @paveldedik, thank you. That's done :)

Copy link
Collaborator

@paveldedik paveldedik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR, it looks good :-), I have just a minor thing.

Also please rebase again (sorry for that, the CI weren't running for your branch so hopefully I fixed that in master - you may need to follow https://www.conventionalcommits.org/en/v1.0.0/ as I added a check for that too).

@alxwrd
Copy link
Contributor Author

alxwrd commented Aug 25, 2022

hi @paveldedik - I've updated the tests and rebased.

To pass the configuration into sentry_sdk.Client, I've used @pytest.mark.parametrize with a notion of ClientParams. If you'd rather this doing a different way, let me know.

Copy link
Collaborator

@paveldedik paveldedik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I like this approach :-)

@paveldedik paveldedik merged commit 56175f6 into kiwicom:master Aug 25, 2022
@alxwrd alxwrd deleted the respect-with-locals-setting branch August 25, 2022 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants