Skip to content

Conversation

@bajtos
Copy link
Contributor

@bajtos bajtos commented Feb 5, 2026

The settlement lag was computed as Date.now() - cdn_payments_settled_until, which produced incorrect results for newly created datasets where cdn_payments_settled_until is still at its default value (1970-01-01). The correct metric is How long has reported usage been waiting for settlement?, which is Date.now() - usage_reported_until.

Refs:

The settlement lag was computed as `Date.now() - cdn_payments_settled_until`,
which produced incorrect results for newly created datasets where
`cdn_payments_settled_until` is still at its default value (1970-01-01).
The correct metric is "how long has reported usage been waiting for
settlement", which is `Date.now() - usage_reported_until`.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
@bajtos bajtos marked this pull request as draft February 5, 2026 15:57
@bajtos
Copy link
Contributor Author

bajtos commented Feb 5, 2026

Hmm, this new approach is not correct either.

Consider the following sequence of events:

  • 00:01 - usage reported
  • 00:02 - payment settled
  • 00:03 - usage reported
  • 00:04 - usage reported
  • 00:05 - usage reported

At 00:06, my code would report a lag of 1 minute (00:06 - 00:05).

However, the actual lag is 3 minutes (00:06 - 00:03) - that's the time since some new usage was reported for the first time after the last settlement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant