Skip to content

fix: stop using f-strings in logs - #665

Merged
danfimov merged 1 commit into
masterfrom
fix-do-not-use-f-strings-for-logs
Aug 29, 2026
Merged

fix: stop using f-strings in logs#665
danfimov merged 1 commit into
masterfrom
fix-do-not-use-f-strings-for-logs

Conversation

@danfimov

Copy link
Copy Markdown
Member

Using f-strings to format a logging message requires that Python eagerly format the string, even if the logging statement is never executed. For our case it's especially bad - we use f-string in debug log to print an entire message. For long messages during profiling with py-spy I found 5% or unnesesary CPU usage just for __str__ method on messages (200Kb each).

Other things:

  • updated ruff, so now we have more standard rules and fixed couple of issues related to them.
  • ignored one more rule rule about argument count

@danfimov danfimov self-assigned this Aug 28, 2026
@danfimov
danfimov requested a review from s3rius August 28, 2026 22:33
@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 40.00000% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.55%. Comparing base (9ce2069) to head (1f7e8f7).

Files with missing lines Patch % Lines
taskiq/cli/worker/process_manager.py 0.00% 6 Missing ⚠️
taskiq/cli/worker/run.py 0.00% 1 Missing ⚠️
taskiq/middlewares/prometheus_middleware.py 0.00% 1 Missing ⚠️
taskiq/receiver/receiver.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master     #665   +/-   ##
=======================================
  Coverage   82.55%   82.55%           
=======================================
  Files          69       69           
  Lines        2717     2717           
=======================================
  Hits         2243     2243           
  Misses        474      474           

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

🚀 新建 features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@danfimov
danfimov requested a review from GefMar August 28, 2026 22:45
@danfimov
danfimov merged commit 9fa2a1c into master Aug 29, 2026
87 of 102 checks passed
@danfimov
danfimov deleted the fix-do-not-use-f-strings-for-logs branch August 29, 2026 08:02
注册 for free to join this conversation on GitHub. Already have an account? 登录 to comment

标签

None yet

项目

None yet

Development

Successfully merging this pull request may close these issues.

2 participants