Skip to content
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

Logging captured warnings with a format string unnecessarily groups warnings together #90715

Closed
mnito mannequin opened this issue Jan 28, 2022 · 5 comments
Closed

Logging captured warnings with a format string unnecessarily groups warnings together #90715

mnito mannequin opened this issue Jan 28, 2022 · 5 comments
Labels
3.11 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@mnito
Copy link
Mannequin

mnito mannequin commented Jan 28, 2022

BPO 46557
Nosy @vsajip, @ericvsmith, @mnito
PRs
  • bpo-46557: Log captured warnings without format string (GH-30975) #30975
  • Files
  • Screen Shot 2022-01-27 at 8.09.37 PM.png: Screenshot of Sentry UI
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2022-01-28.00:38:52.260>
    labels = ['type-feature', 'library', '3.11']
    title = 'Logging captured warnings with a format string unnecessarily groups warnings together'
    updated_at = <Date 2022-03-15.09:01:07.221>
    user = 'https://github.com/mnito'

    bugs.python.org fields:

    activity = <Date 2022-03-15.09:01:07.221>
    actor = 'vinay.sajip'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2022-01-28.00:38:52.260>
    creator = 'mnito'
    dependencies = []
    files = ['50592']
    hgrepos = []
    issue_num = 46557
    keywords = ['patch']
    message_count = 4.0
    messages = ['411947', '411950', '411956', '415228']
    nosy_count = 3.0
    nosy_names = ['vinay.sajip', 'eric.smith', 'mnito']
    pr_nums = ['30975']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue46557'
    versions = ['Python 3.11']

    @mnito
    Copy link
    Mannequin Author

    mnito mannequin commented Jan 28, 2022

    Systems that aggregate logs like Sentry will group all captured warnings under the same event which makes it difficult to assess common warnings

    @mnito mnito mannequin added type-bug An unexpected behavior, bug, or error 3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes 3.11 only security fixes stdlib Python modules in the Lib dir labels Jan 28, 2022
    @ericvsmith
    Copy link
    Member

    Could you give an example of the problem?

    @mnito
    Copy link
    Mannequin Author

    mnito mannequin commented Jan 28, 2022

    Of course, here's an example script to reproduce:

    import logging
    import warnings
    
    import sentry_sdk
    from sentry_sdk.integrations.logging import LoggingIntegration
    
    logging.captureWarnings(True)
    
    sentry_logging = LoggingIntegration(
        level=logging.INFO,
        event_level=logging.WARNING
    )
    
    sentry_sdk.init(
        "<ingest URL>",
        traces_sample_rate=1.0,
        integrations=[
            LoggingIntegration(
                level=logging.INFO,
                event_level=logging.WARNING
            )
        ]
    )
    
    warnings.warn("A warning")
    warnings.warn("Another warning")
    

    I attached a file of what it looks like in the Sentry UI. Notice both warnings under the same issue. When logging warnings directly with the logging module, each message arrives as a separate issue. These warnings from the warnings module are both grouped together under the same issue since Sentry groups all logs with the same format string together.

    @vsajip vsajip added type-feature A feature request or enhancement and removed 3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes type-bug An unexpected behavior, bug, or error labels Jan 28, 2022
    @vsajip
    Copy link
    Member

    vsajip commented Mar 15, 2022

    New changeset d8066b4 by Michael P. Nitowski in branch 'main':
    bpo-46557: Log captured warnings without format string (GH-30975)
    d8066b4

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @vsajip
    Copy link
    Member

    vsajip commented Jul 13, 2022

    Closing, as believed to be resolved.

    @vsajip vsajip closed this as completed Jul 13, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.11 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    Development

    No branches or pull requests

    2 participants