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

feat(logs): Make the logging integration send Sentry logs #4143

Merged
merged 18 commits into from
Mar 27, 2025

Conversation

colin-sentry
Copy link
Member

@colin-sentry colin-sentry commented Mar 17, 2025

We have integrations that make the python logger create breadcrumbs and issues. This adds a third handler which creates Sentry logs on logger.log statements.

Enable the logger with:

sentry_sdk.init(
    ...
    _experiments={
        "enable_sentry_logs": True
    }
)

some_logger = logging.Logger("some-logger")
some_logger.info('Finished sending answer! #chunks=%s', chunks)

Screenshot 2025-03-17 at 4 12 27 PM

Refs #4150

Copy link

codecov bot commented Mar 17, 2025

Codecov Report

Attention: Patch coverage is 75.00000% with 19 lines in your changes missing coverage. Please review.

Project coverage is 79.57%. Comparing base (6f49bfb) to head (5910b07).
Report is 1 commits behind head on master.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
sentry_sdk/integrations/logging.py 71.15% 2 Missing and 13 partials ⚠️
sentry_sdk/client.py 76.47% 0 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4143      +/-   ##
==========================================
- Coverage   79.57%   79.57%   -0.01%     
==========================================
  Files         141      141              
  Lines       15738    15790      +52     
  Branches     2675     2696      +21     
==========================================
+ Hits        12524    12565      +41     
+ Misses       2369     2368       -1     
- Partials      845      857      +12     
Files with missing lines Coverage Δ
sentry_sdk/_experimental_logger.py 100.00% <100.00%> (ø)
sentry_sdk/consts.py 92.85% <ø> (ø)
sentry_sdk/client.py 79.00% <76.47%> (-0.17%) ⬇️
sentry_sdk/integrations/logging.py 82.78% <71.15%> (-6.33%) ⬇️

... and 3 files with indirect coverage changes

@antonpirker antonpirker changed the title feat(logs): Make the python logger go to ourlogs feat(logs): Make the logging integration send Sentry logs Mar 18, 2025
Copy link
Member

@antonpirker antonpirker left a comment

Choose a reason for hiding this comment

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

All in all looks good. I have some questions

@antonpirker
Copy link
Member

@colin-sentry I have moved the new parameter sentry_logs_level to the end of the parameter list, so we do not break peoples setup if they use positional parameters.

Copy link
Member

@antonpirker antonpirker left a comment

Choose a reason for hiding this comment

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

This looks good now. 🔥

@antonpirker antonpirker merged commit 2f4b028 into master Mar 27, 2025
138 of 139 checks passed
@antonpirker antonpirker deleted the logger_ourlogs branch March 27, 2025 08:52
@AbhiPrasad AbhiPrasad mentioned this pull request Mar 27, 2025
3 tasks
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