Skip to content
CAI
Software that uses CAICheck a score

klarna/speed_trap

70.1

Strong · 17 September 2026

1k

lines of production code

Erlang

primary language

1

measurement over time

CAI band scale
CAI lens gauges

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 watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Baseline

  • First survey — no prior run to compare against. CAI 70.

Lenses

  • Code Health 100
  • Architecture 69
  • Maturity 62
  • Readiness 78
  • Security 92

Changes since last survey

  • 53 commits — 45 feature/other, 8 fixes

By area

  • (repo) — 21 commits
  • (root) — 15 commits
  • .github/workflows — 4 commits
  • src/speed_trap.erl — 4 commits
  • src/speed_trap_token_bucket.erl — 3 commits
  • test/speed_trap_tests.erl — 3 commits
  • src/speed_trap_template.erl — 2 commits
  • .github/CODEOWNERS — 1 commit

Notable commits

  • fix: Fix badges
  • fix: Fix edoc generation
  • fix: Merge pull request #14 from andreashasse/type-fix
  • fix: Merge pull request #17 from klarna-incubator/fix-modify-for-templates
  • fix: Merge pull request #23 from klarna/fix-edoc
  • fix: Merge pull request #8 from klarna-incubator/fix-badges-in-readme
  • fix: Some minor fixes in order to fix uploading to hex.pm
  • fix: Type fix
  • change: Add 'Last Updated' badge
  • change: Add CODEOWNERS file
  • change: Add OTP28 and drop OTP 25 from the test pipeline
  • change: Add build for OTP 26
  • change: Add initial version of speed_trap
  • change: Add more granular validations for min/max bucket_size, fix typo in docs
  • change: Add some more tests which exercise speed_trap_options
  • change: Add support for dynamic rate limiting capability in speed_trap
  • change: Add tests
  • change: Avoid speed_trap_token_bucket:return_token/1 from setting the bucket to 1
  • change: Change template modifications to overrides
  • change: Do not run modify if all options are the same
  • …and 33 more

Written by watchdog.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 17 September 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.09.12 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-f94092f054c1.