question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

in_app_include/in_app_exclude params not appearing to work

See original GitHub issue

Environment

How do you use Sentry? Sentry SaaS (sentry.io)

Which SDK and version? Version 0.20.3.

Steps to Reproduce

We have a Python package that we distribute to our users. We need the handled/unhandled exceptions that occur inside our library to be reported to sentry. Assuming the following initialization of sentry (verbatim copy):

def init_sentry(
    tags: dict = {},
    disabled: bool = False,
):
    """
    Initialize sentry. Override the default values with the following env vars:
    1. CORTEX_TELEMETRY_SENTRY_DSN
    2. CORTEX_TELEMETRY_SENTRY_ENVIRONMENT
    3. CORTEX_TELEMETRY_DISABLE
    """

    dsn = CORTEX_TELEMETRY_SENTRY_DSN
    environment = CORTEX_TELEMETRY_SENTRY_ENVIRONMENT

    if not disabled and os.getenv("CORTEX_TELEMETRY_DISABLE") is True:
        return

    if os.getenv("CORTEX_TELEMETRY_SENTRY_DSN", "") != "":
        dsn = os.environ["CORTEX_TELEMETRY_SENTRY_DSN"]

    if os.getenv("CORTEX_TELEMETRY_SENTRY_ENVIRONMENT", "") != "":
        environment = os.environ["CORTEX_TELEMETRY_SENTRY_ENVIRONMENT"]

    release = CORTEX_VERSION

    user_id = None
    client_id_file_path = pathlib.Path.home() / ".cortex" / "client-id.txt"
    if client_id_file_path.is_file():
        user_id = client_id_file_path.read_text()

    sentry_sdk.init(
        dsn=dsn,
        environment=environment,
        release=release,
        ignore_errors=[CortexBinaryException],
        attach_stacktrace=True,
        in_app_include=["cortex"],
        in_app_exclude=[""],
        integrations=[
            LoggingIntegration(event_level=None, level=None),
            ThreadingIntegration(propagate_hub=True),
        ],
    )

    if user_id:
        sentry_sdk.set_user({"id": user_id})

    for k, v in tags.items():
        sentry_sdk.set_tag(k, v)

The above initialization occurs when the user imports specific modules of our package. Imagine our source-code looks like:

# our mypackage.generic.module

init_sentry()

# a bunch of function/class definitions that we want to encompass with sentry

Expected Result

Problem is that exceptions that occur outside our package are still recorded by the sentry client (hub + client + scope) that we initialized in our module(s). I tried adding the name of our package in in_app_include, but to no avail. We only want to capture events that happen within our package. Any idea?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
untitakercommented, Feb 19, 2021

A combination of atexit stdlib module and hub.flush() should do the trick. Normally the default integrations take care of this for you but they only flush for the current hub, not all hubs in existence.

0reactions
RobertLuciancommented, Feb 20, 2021

Thanks! I’ll close this now!

Read more comments on GitHub >

github_iconTop Results From Across the Web

POST json body not appearing in params #290 - rswag ...
POST json body not appearing in params #290 ... Currently I am having to use request.raw_post in the controller and parse the json...
Read more >
React-Router params not working as expected returns ...
My question is when I don't pass any parameter in the hibachi component I get this as result :id I have tried putting...
Read more >
URLSearchParams - Web APIs - MDN Web Docs
Chrome Edge URLSearchParams Full support. Chrome49. Toggle history Full support. Edge... @@iterator Full support. Chrome49. Toggle history Full support. Edge... URLSearchParams() constructor Full support. Chrome49. Toggle...
Read more >
Solved: URL Query Parameters Not Working
Solved: Trying to run a query on our instance using parameters recommended in the SN wiki. However, the results are not correct. Below...
Read more >
params keyword for parameter arrays - C# reference
When you call a method with a params parameter, you can pass in: A comma-separated list of arguments of the type of the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found