Skip to content

Logging updates & feedback from testing#4726

Open
vEpiphyte wants to merge 62 commits intovisi-loggingfrom
visi-logging-epiphyte-fb
Open

Logging updates & feedback from testing#4726
vEpiphyte wants to merge 62 commits intovisi-loggingfrom
visi-logging-epiphyte-fb

Conversation

@vEpiphyte
Copy link
Contributor

@vEpiphyte vEpiphyte commented Feb 3, 2026

  • Updated examples in devops documentation.
  • Updates to synapse.lib.logging
    • Added a shutdown() API which causes the log pump to wake up, drain existing todo items, then exit. This is needed for application / command shutdown so we don't await the bg task.
    • Added BaseExceptionGroup handling to excinfo.
    • Captured missing src data in excinfo tracebacks as <none>.
    • Fixed Garbage Collection issue in _pumpLogStream; the last window objects in _log_wins was held onto and would not be GC'd even if its calling task was completed.
  • Base.main() now calls logging.shutdown().
  • synapse.lib.cmd.wrapmain() now calls logging.shutdown().
  • Updated all existing uses of extra=... definitions to use the new getLogExtra APIs so there would not be a regression in logged parameters.
  • Added user and username information to the Storm execution errors so that information would be consistent with the Storm query executed... information.
  • Rewrote test_lib_logging.py to increase coverage and add more focused behavioral tests.
  • Changed LoggerStream.expect() to raise an AssertionError instead of a SynErr to avoid the possibility of a test catching a SynErr by mistake when they wanted a test assertion to fail.
  • Marked synapse.lib.structlog.JsonFormatter class as deprecated.

…d AFTER reset is called are no longer being emitted by the handlers. Probably need to split the difference between a reset() method and a shutdown() method, where the shutdown method re-installs a stream handler so messages sent after shutdown are not lost to the ether.
…is drained; reset, then a simple StreamHandler reinstalled. This allows for cleaner service / tool teardown as we've exited application logic at that point and may have atexit handler logic running.
@codecov
Copy link

codecov bot commented Feb 3, 2026

Codecov Report

❌ Patch coverage is 98.30508% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 97.67%. Comparing base (2f8844f) to head (1d2bfd2).

Files with missing lines Patch % Lines
synapse/lib/logging.py 96.66% 1 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff                @@
##           visi-logging    #4726      +/-   ##
================================================
- Coverage         97.73%   97.67%   -0.07%     
================================================
  Files               299      299              
  Lines             62492    62508      +16     
================================================
- Hits              61079    61056      -23     
- Misses             1413     1452      +39     
Flag Coverage Δ
linux 97.67% <98.30%> (+<0.01%) ⬆️
linux_replay ?

Flags with carried forward coverage won't be shown. Click here to find out more.

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

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

@vEpiphyte vEpiphyte added bug deprecation enhancement and removed DO-NOT-MERGE Do not merge this PR yet. labels Feb 17, 2026
logmesg = f'{logmesg} - {mesg}'

extra = self.core.getLogExtra(text=text)
extra = self.core.getLogExtra(text=text, user=user.iden, username=user.name)
Copy link
Contributor

Choose a reason for hiding this comment

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

If these are authenticated users, they should be automatically logged outside of the arbitrary info via the scope. We should only add them directly to extras for things like unauthenticated requests. If they don't currently get picked up, the issue is with the use of scope.

Copy link
Contributor Author

@vEpiphyte vEpiphyte Feb 27, 2026

Choose a reason for hiding this comment

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

In remote use cases, mainly driven from Optic, the link user is not going to reflect the user that is actually responsible for executing the queries. This allow us to know the who-something-was-executed-for when something went wrong; especially since we're outside of the transfer of control to the Storm user when handling these exceptions.

@vEpiphyte vEpiphyte marked this pull request as ready for review February 27, 2026 18:51
@vEpiphyte vEpiphyte changed the title WIP - Logging updates feedback from testing Logging updates & feedback from testing Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants