Skip to content

Fix bug due to log(0) being undefined. Assisted-by: claude/fable5-2 - #518

Merged
liammclennan merged 2 commits into
datalust:devfrom
liammclennan-ro:fix-histogram-bug
Nov 27, 2026
Merged

liammclennan merged 2 commits into
datalust:devfrom
liammclennan-ro:fix-histogram-bug

Conversation

@liammclennan-ro

Copy link
Copy Markdown
Contributor

RequestLoggingMiddleware records HTTP request durations as whole milliseconds, so a fast request records 0. The histogram's bucket calculation took log(0), which gave an infinite bucket midpoint, and System.Text.Json refuses to write that. Each "Metrics sampled" event containing such a bucket made its whole batch fail to serialise. This broke seq bench --with-ingestion.

histogram.Record(100);

var midpoint = Assert.Single(histogram.Buckets).Key;
Assert.InRange(midpoint, 100 / Math.Pow(2, 1 / 8d), 100 * Math.Pow(2, 1 / 8d));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pretty awful reading these bounds as expressions - could just be 90, 110?

@liammclennan-ro

Copy link
Copy Markdown
Contributor Author

Merging. Build error is a known Github actions MCP race condition that I will fix in the next PR.

@liammclennan
liammclennan merged commit 74bba4b into datalust:dev Nov 27, 2026
1 of 2 checks passed
@liammclennan-ro
liammclennan-ro deleted the fix-histogram-bug branch November 27, 2026 05:18
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.

3 participants