Skip to content

fix(logger): writer level filtering - #1761

Open
ajw221 wants to merge 4 commits into
jbuckmccready/logging-improvementsfrom
adamw/fix-logger-max-level-bug
Open

fix(logger): writer level filtering#1761
ajw221 wants to merge 4 commits into
jbuckmccready/logging-improvementsfrom
adamw/fix-logger-max-level-bug

Conversation

@ajw221

@ajw221 ajw221 commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Intent

  • Fix issue where logger writes values that should have been ignored. Currently only the reader in streamLogs is filtering the max log level, which has the side effect of potentially making the swap buffer running out of space if a log was being written, but should have been filtered out for the actual max log level provided.

Implementation

  • Added max log level checking to `logf``
  • Consolidated Filter while loop logic into new Iterator type

Ramifications

  • Issue only occurred when I was running v2 shred, gossip, and net for ~40min, when the swap buffer became maxed out. The panic pointed to the only trace log in onDiscoveredValue, which was not outputted at all during the entire run.

Tests

  • Added unit tests for around ensuring previous logic doesn't regress

@ajw221 ajw221 self-assigned this Jul 24, 2026
@github-project-automation github-project-automation Bot moved this to 🏗 In progress in Sig Jul 24, 2026
@ajw221
ajw221 requested review from InKryption and dnut and removed request for InKryption July 24, 2026 20:08
@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.25000% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
v2/services/telemetry.zig 0.00% 2 Missing ⚠️
v2/lib/telemetry.zig 97.36% 1 Missing ⚠️
Files with missing lines Coverage Δ
v2/lib/telemetry/log.zig 76.58% <100.00%> (+11.52%) ⬆️
v2/lib/telemetry/tests/TestLogStore.zig 97.90% <100.00%> (ø)
v2/lib/telemetry.zig 93.13% <97.36%> (+2.70%) ⬆️
v2/services/telemetry.zig 0.00% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dnut dnut added external and removed external labels Jul 27, 2026
yewman
yewman previously approved these changes Jul 28, 2026

@yewman yewman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

@ajw221
ajw221 changed the base branch from main to jbuckmccready/logging-improvements July 28, 2026 13:16

@InKryption InKryption left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just a couple small details, otherwise lgtm.

Comment thread v2/lib/telemetry.zig Outdated
Comment thread v2/lib/telemetry.zig Outdated
Comment thread v2/lib/telemetry.zig Outdated
@github-project-automation github-project-automation Bot moved this from 🏗 In progress to 👀 In review in Sig Jul 28, 2026
@jbuckmccready
jbuckmccready force-pushed the jbuckmccready/logging-improvements branch 2 times, most recently from 841ddd5 to bddebca Compare July 30, 2026 15:21
ajw221 added 3 commits July 30, 2026 11:58
- Compute the most verbose level across all log filters at init and
  store on Region.Info.max_log_level
- Loggers carry max_level (preserved through withScope/from) and bail
  early in Entry.print when a message exceeds it
- Avoids double-rendering (length computation + write) and swap buffer
  writes for messages that streamLogs would drop anyway
- Add log.maxLevelEncoded helper; returns .trace on empty/malformed
  input so the telemetry service still surfaces the diagnostic
- Verify logf drops entries more verbose than max_level and writes
  matching entries whole
- Confirm max_level propagates through withScope/from and that
  acquireLogger picks up the region's filter maximum
- Exercise maxLevelEncoded on empty, default, multi-filter, and
  truncated inputs, plus a bound check against findClosestFilter for
  every named and fall-through (service, scope) pair
- Add Filter.Iterator wrapping the fixed-reader/takeStruct/
  getFilterFromFixedReader pattern with a single InvalidFilter error
- Use it in maxLevelEncoded, its tests, and services/telemetry.zig
  filter decoding to eliminate duplication
@ajw221
ajw221 force-pushed the adamw/fix-logger-max-level-bug branch from 0c39c7f to f82806c Compare July 30, 2026 16:04
…yout inputs

- Drop default `.trace` on Region.Info.max_log_level and Logger.max_level so
  callers must set them, preventing silent regressions where a logger fails
  to consult the region's filters
- Extract Region.Info.Lengths struct capturing the only fields that affect
  region layout, and make regionSize take Lengths rather than a full Info
- Update noop logger and TestLogStore.logger to set max_level explicitly
- Reword the acquireLogger test comment now that the default is gone
@ajw221
ajw221 force-pushed the adamw/fix-logger-max-level-bug branch from f82806c to 107a8c9 Compare July 30, 2026 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 👀 In review

Development

Successfully merging this pull request may close these issues.

5 participants