refactor(ratelimit): remove per-window token tracking from proxy
Window token counts are now computed in Grafana using the @ modifier with dashboard variables derived from proxy_usage_resets_at. This eliminates in-memory state, file persistence, and restart sensitivity. Removes: TokensIn/Out, RecordTokens, setResetTime, persist.go, window_tokens observable gauges. -171 lines.
This commit is contained in:
@@ -82,21 +82,4 @@ 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
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user