Skip to content

feat: log warning when SSE flush to client is slow#269

Merged
mtojek merged 7 commits into
mainfrom
66-slow-client-detection
Apr 17, 2026
Merged

feat: log warning when SSE flush to client is slow#269
mtojek merged 7 commits into
mainfrom
66-slow-client-detection

Conversation

@mtojek

@mtojek mtojek commented Apr 17, 2026

Copy link
Copy Markdown
Member

Fixes: #66

Adds slow client detection to the EventStream SSE sender. After each flush, the elapsed time is measured using an injected quartz.Clock. If it exceeds 500ms, a Warn log is emitted with the flush duration, making slow clients immediately visible in logs without requiring distributed tracing infrastructure.

quartz.Clock is injected into EventStream so tests can simulate slow flushes by advancing a mock clock — no real sleeping required.

@mtojek mtojek self-assigned this Apr 17, 2026
@mtojek
mtojek marked this pull request as ready for review April 17, 2026 10:24
@mtojek
mtojek requested review from dannykopping and pawbana April 17, 2026 10:24

@dannykopping dannykopping left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Mostly looks good, but this log isn't actionable right now.

Comment thread intercept/eventstream/eventstream.go Outdated
Comment thread intercept/eventstream/eventstream_test.go Outdated
Comment thread intercept/eventstream/eventstream_test.go Outdated
Comment thread .claude/settings.local.json Outdated
Comment thread intercept/eventstream/eventstream.go Outdated
mtojek added 5 commits April 17, 2026 13:19
Adds slow client detection to the EventStream SSE sender. After each
flush, the elapsed time is measured using an injected quartz.Clock.
If it exceeds 500ms, a Warn log is emitted with the flush duration,
making slow clients immediately visible in logs without requiring
distributed tracing infrastructure.

quartz.Clock is injected into EventStream so tests can simulate slow
flushes by advancing a mock clock — no real sleeping required.
Apply reviewer feedback:
- Replace custom captureSink with sloghuman.Sink(&strings.Builder{})
- Use exported SlowFlushThreshold constant instead of hardcoded 600ms
@mtojek
mtojek force-pushed the 66-slow-client-detection branch from d40c2ff to f5c9701 Compare April 17, 2026 11:19
@mtojek
mtojek requested a review from dannykopping April 17, 2026 11:41

@dannykopping dannykopping left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM, just one nit
I don't need to review again
Thanks a lot @mtojek!

Comment thread intercept/eventstream/eventstream.go Outdated
@mtojek
mtojek merged commit fd245f4 into main Apr 17, 2026
4 checks 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.

Slow client detection

2 participants