Skip to content

Add include_source_context option #2017

Closed

Description

@antonpirker

Problem Statement

Some users do not like the source context to be there and want to disable it.

Solution Brainstorm

For this we need to add a SDK option include_source_context that defaults to True.
If set to false, the source context should not be included.

Here is probably the place where to decide whether to add the source context or not:
https://github.com/getsentry/sentry-python/blob/antonpirker/celery-beat-wo-restart/sentry_sdk/utils.py#L614-L625

Activity

  1. added a commit that references this issue on Apr 17, 2023
    e61b1e7
  2. maxkosty commented on Apr 20, 2023

    @maxkosty

    As of right now this can be removed in before_send() as follows:

    def before_send(event, hint):
        placeholder = "*** Code context removed in before_send ***"
        for exception in event.get("exception", {}).get("values", []):
            for frame in exception.get("stacktrace", {}).get("frames", []):
                for key in ["pre_context", "post_context"]: # add "context_line" to remove line itself
                    if key in frame and type(frame[key]) == list:
                        frame[key] = [placeholder] * len(frame[key]) 
    
        return event
    

    Screenshot 2023-04-20 at 12 11 07 PM

  3. sentrivana commented on May 11, 2023

    @sentrivana
    Collaborator

    Reopening since there's a bit missing in order to finish the implementation fully.

  4. antonpirker commented on Jun 5, 2023

    @antonpirker
    ContributorAuthor

    Documentation for this option is still missing, but the option itself is already release in version 1.23.0

  5. antonpirker commented on Jun 5, 2023

    @antonpirker
    ContributorAuthor

    documentation PR is on the way: getsentry/sentry-docs#7090

    So we can close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions