Skip to content

Add BufferedLogSink drop visibility (counter + error handler)#15

Merged
DJGosnell merged 1 commit intomasterfrom
feature/buffered-sink-drop-visibility
Mar 3, 2026
Merged

Add BufferedLogSink drop visibility (counter + error handler)#15
DJGosnell merged 1 commit intomasterfrom
feature/buffered-sink-drop-visibility

Conversation

@DJGosnell
Copy link
Member

Summary

  • Closes BufferedLogSink drop visibility (counter + error handler) #11
  • Adds atomic DroppedCount property to BufferedLogSink for monitoring dropped messages
  • Routes drop events through InternalErrorHandler with per-second throttling via LogDroppedException
  • Threads errorHandler through FileSink, StreamSink, and LogConfigBuilder helper methods

Reason for Change

When BufferedLogSink's bounded channel is full, TryWrite() fails and messages are silently dropped. Applications have no way to detect log data loss under back-pressure.

Impact

  • BufferedLogSink now exposes a DroppedCount property queryable for health checks and metrics
  • If InternalErrorHandler is configured, it receives LogDroppedException on the first drop and then at most once per second
  • All existing behavior is preserved — no changes to normal (non-drop) code paths

Migration Steps

No migration required. The new errorHandler parameter on BufferedLogSink, FileSink, and StreamSink constructors is optional with a default of null. Existing code compiles and behaves identically.

Performance Considerations

  • Drop path adds one Interlocked.Increment and one Volatile.Read — negligible overhead
  • Throttle CAS prevents cascading error handler calls under sustained load
  • Normal (non-drop) write path is unchanged

Security Considerations

None.

Breaking Changes

  • Consumer-facing: None
  • Internal: None

Surface silent message drops when the bounded channel is full by adding
an atomic DroppedCount property and throttled InternalErrorHandler
notifications via a new LogDroppedException type.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@DJGosnell DJGosnell merged commit 638e9b3 into master Mar 3, 2026
1 check passed
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.

BufferedLogSink drop visibility (counter + error handler)

1 participant