klarna/speed_trap
66.4
Adequate · 15 November 2026
1k
lines of production code
Erlang
primary language
4
measurements over time
What this system is
Speed Trap is an Erlang library implementing a Token Bucket rate limiter with support for per-node tracking and no external dependencies. It provides core rate-limiting features such as configurable bucket sizes, dynamic scaling based on rejection rates, and the ability to block or unblock specific identifiers. The system also supports template-based configurations for automatic bucket creation and includes comprehensive test coverage for its limiting logic.
Features
Initial release of speed\_trap, a Token Bucket rate limiter for Erlang
This entry introduces speed\_trap, a basic Token Bucket rate limiter for Erlang that uses atomics for per-node tracking with no external dependencies. It supports configurable parameters (bucket\_size, refill\_interval, refill\_count, delete\_when\_full) and an override mode (none, not\_enforced, blocked) to allow soft-launches or forced blocking. The library also includes a dynamic rate limiter that automatically adjusts bucket\_size based on rejection rates, featuring automatic upscaling and downscaling with configurable bounds (min/max bucket\_size), scaling intervals, and thresholds. The release includes documentation, build configuration via rebar3, and test coverage.
(repo-wide) · high confidence
Introduce speed\_trap rate limiter with dynamic scaling and template overrides
Adds the speed\_trap application, a token-bucket-based rate limiter for Erlang. It supports creating buckets with arbitrary IDs, modifying limits on the fly, and blocking/unblocking specific IDs. A new dynamic rate limiter automatically adjusts bucket sizes up or down based on rejection rates, with safeguards to prevent downscaling when traffic exceeds the reduced capacity. Template-based configurations can be defined to auto-create buckets for matching IDs, and overrides for these templates can be stored and deleted independently.
src · high confidence
Test coverage
Added unit tests for speed\_trap rate limiting functionality
Added comprehensive EUnit tests for the speed\_trap module, covering core rate-limiting behaviors such as bucket creation, token consumption, refill intervals, and blocking overrides. The test suite validates error handling for non-existent traps, duplicate creation attempts, and deletion, as well as dynamic modification of bucket configurations like size and refill rates. It also exercises the try\_pass\_all API for managing multiple traps simultaneously and verifies that blocking a specific trap correctly isolates its traffic while allowing others to proceed.
test · high confidence
Housekeeping
Placeholder for EUnit test directory
A .gitkeep file has been added to the .eunit directory to ensure the folder is tracked by version control, establishing a location for future EUnit test files.
.eunit · high confidence
Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Score
- CAI 67 → 66 (-1.1)
- Rubric changed (rubric-2026.10.5 → rubric-2026.11.4) — scores are not directly comparable.
Lenses
- Code Health 100 → 100 (+0.0)
- Architecture 69 → 69 (+0.0)
- Maturity 56 → 56 (+0.0)
- Readiness 80 → 73 (-7.7)
- Security 92 → 92 (+0.0)
Resolved (1)
- Off-boarding risk: anonymized user #1
New (3)
- Flaky test: speed_trap_tests:0 delete_when_full_test
- Flaky test: speed_trap_tests:0 dynamic_rate_limiter_gradual_scaling_test
- Off-boarding risk: anonymized user #1
Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
klarna/speed_trap was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 15 November 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit 6cddae7eaa87ab2d05f75fc6b5aaec9e4c8b204c — the exact code this score is about.
- Scored under rubric-2026.11.4 — the same rubric and the same method as every other entry in this index.
- Measured by Canine Code Analyzer (cca.canine.dev) using cca measure-2026.11.65+preprod-3c33c1882dc1.