Revert "refactor(ratelimit): remove in-memory per-window token tracking"

This reverts commit eda66ff7d4.
This commit is contained in:
Alexander
2026-04-14 13:50:34 +02:00
parent eda66ff7d4
commit 0ab1896eef
3 changed files with 62 additions and 7 deletions
+17
View File
@@ -82,4 +82,21 @@ func InitMetrics(meter metric.Meter, tracker *ratelimit.Tracker) {
}),
)
meter.Int64ObservableGauge("proxy.usage.window_tokens.input",
metric.WithDescription("Proxy input tokens in current window"),
metric.WithInt64Callback(func(_ context.Context, o metric.Int64Observer) error {
o.Observe(tracker.FiveHour().TokensIn, metric.WithAttributes(attr5h))
o.Observe(tracker.SevenDay().TokensIn, metric.WithAttributes(attr7d))
return nil
}),
)
meter.Int64ObservableGauge("proxy.usage.window_tokens.output",
metric.WithDescription("Proxy output tokens in current window"),
metric.WithInt64Callback(func(_ context.Context, o metric.Int64Observer) error {
o.Observe(tracker.FiveHour().TokensOut, metric.WithAttributes(attr5h))
o.Observe(tracker.SevenDay().TokensOut, metric.WithAttributes(attr7d))
return nil
}),
)
}