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

Structlog processor formatter #1289

Merged
merged 6 commits into from
Jan 29, 2025
Merged

Conversation

lrafeei
Copy link
Contributor

@lrafeei lrafeei commented Jan 24, 2025

This PR provides a fix for the case where structlog's ProcessorFormatter is used as a logging.Formatter for both logging as well as structlog log entries.

For more information about this functionality: https://www.structlog.org/en/stable/standard-library.html#rendering-using-structlog-based-formatters-within-logging

Copy link

github-actions bot commented Jan 24, 2025

🦙 MegaLinter status: ✅ SUCCESS

Descriptor Linter Files Fixed Errors Elapsed time
✅ PYTHON bandit 1 0 4.75s
✅ PYTHON black 2 0 0 0.86s
✅ PYTHON flake8 2 0 0.45s
✅ PYTHON isort 2 0 0 0.3s
✅ PYTHON pylint 2 0 3.27s

See detailed report in MegaLinter reports
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is graciously provided by OX Security

@lrafeei lrafeei linked an issue Jan 24, 2025 that may be closed by this pull request
@codecov-commenter
Copy link

codecov-commenter commented Jan 24, 2025

Codecov Report

Attention: Patch coverage is 54.54545% with 5 lines in your changes missing coverage. Please review.

Project coverage is 81.30%. Comparing base (454709e) to head (3df1d10).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
newrelic/hooks/logger_structlog.py 54.54% 4 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1289   +/-   ##
=======================================
  Coverage   81.29%   81.30%           
=======================================
  Files         201      201           
  Lines       22174    22185   +11     
  Branches     3519     3520    +1     
=======================================
+ Hits        18027    18037   +10     
- Misses       2981     2984    +3     
+ Partials     1166     1164    -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@lrafeei lrafeei marked this pull request as ready for review January 24, 2025 19:41
@lrafeei lrafeei requested a review from a team as a code owner January 24, 2025 19:41
Comment on lines 71 to 72
elif isinstance(event, tuple) and event[0][0] and "event" in event[0][0]:
event[0][0]["event"] = message
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's throw this into a try/except block to prevent crashes, make this an else and then an if underneath.

@mergify mergify bot removed the tests-failing label Jan 28, 2025
@umaannamalai umaannamalai added this to the v10.5.0 milestone Jan 29, 2025
@TimPansino TimPansino merged commit 84a5d46 into main Jan 29, 2025
56 checks passed
@TimPansino TimPansino deleted the structlog-processor-formatter branch January 29, 2025 18:32
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.

Partially incompatible with structlog configuration
4 participants