Skip to content

All versions since v1.2.0

v1.2.0 Latest

✨ New Features & Enhancements

1. Pluggable Observability & Telemetry Engine (metrics/)

  • Core Observer Interface: Introduced metrics.Observer interface and metrics.Event snapshot data structure.
  • Zero-Allocation Guarantee: Evaluated at $0\text{ B/op}$ and $0\text{ allocs/op}$ when telemetry observers are disabled.
  • Prometheus Support (metrics/prometheus): Native collectors for evaluation counts (distlimit_requests_total), execution latency histograms (distlimit_evaluation_duration_seconds), and hybrid failovers (distlimit_hybrid_fallback_total).
  • OpenTelemetry Support (metrics/otel): Turnkey OTel MeterProvider integration (Int64Counter & Float64Histogram).

2. Lock-Free Dynamic Policy & Runtime Reload Engine

  • Atomic Policy Swapping: Limiter internal state refactored to atomic.Pointer[Policy]. Calling limiter.UpdatePolicy(limit, window) updates limits instantly with zero lock contention ($O(1)$ zero lock delay).
  • Multi-Tenant PolicyResolver: Added PolicyResolver interface allowing dynamic tier-based rate limit rules per key (e.g., VIP vs Free tiers) via WithPolicyResolver().

3. Middleware Route Labeling (WithRouteLabeling)

  • Context helper utilities ContextWithRoute(ctx, route) and RouteFromContext(ctx).
  • Added WithRouteLabeling(true) option across all middleware adapters (net/http, Gin, Echo v4, Echo v5, Fiber v3, and gRPC). This passes parametrized route patterns (e.g. /api/v1/users/:id or gRPC FullMethod) directly into metric labels.

📂 Working Examples


What’s Changed

Full Changelog: https://github.com/balramadan/distlimit/compare/v1.1.1...v1.2.0