Repository navigation
Conversation
Kaiten now makes usage reports idempotent and keeps their history; the Go SDK models both (kaitencloud/sdk-go#1). The CLI follows. - instances usage report --transaction-id: Kaiten applies the report at most once per key, so the SDK retries it on transient failures and running the command again is safe. A replayed report and dropped metadata are noted on stderr; stdout stays the usage document. The flag wins over a key in --file or --payload. - A malformed key exits 2 before any request; a key already used for a different report is a 409 and exits 5. - instances usage history <instance> <entitlement>: the accepted reports, with the counter before and after each one, the delta, the limit and the key; --from, --to, --transaction-id, --limit. - instances usage export [<instance> <entitlement>]: CSV or NDJSON streamed to stdout or --output-file, for one pair (366 days per run) or, without arguments, the whole organization (31 days per run) with --instance, --instance-id, --entitlement and --entitlement-id. Exports run on a client without an overall timeout and outside the command's 15 s deadline; a file is written as <name>.partial and renamed once complete. - github.com/kaitencloud/sdk-go is pinned to the branch of kaitencloud/sdk-go#1 until it is released. Signed-off-by: Tom Ribuot <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR change?
CLI support for two Kaiten features: idempotent usage reports (
transactionId) and the usage history. Server: kaitencloud/kaiten#16. SDK: kaitencloud/sdk-go#1.kaiten instances usage report … --transaction-id <id>. Kaiten applies a keyed report at most once, so the SDK retries it on network errors and 500/502/503/504, and running the command again is safe. A replayed report ("already counted") and dropped metadata (above 4 KiB) are noted on stderr; stdout stays the usage document scripts read. The flag overrides a key given in--file/--payload.2before any request. A key already used for a different report is a 409 and exits5, like any rejection: a correction is a new report under a new key.kaiten instances usage history <instance> <entitlement>. The accepted reports in order, with the counter before and after each one, the delta, the limit and the key. Flags:--from,--to(last 30 days by default),--transaction-id,--limit.kaiten instances usage export [<instance> <entitlement>]. CSV (default) or NDJSON, streamed to stdout or--output-file:--instance,--instance-id,--entitlementand--entitlement-id. The ID filters reach deleted instances and entitlements.<name>.partialand renamed when complete.github.com/kaitencloud/sdk-gois pinned to a pseudo-version of feat: usage report transaction IDs and the usage history sdk-go#1's branch. Before merging: merge and tag that PR, then bump the pin to the tag.Why?
A report that timed out could not be retried safely: it might count twice. A key makes the retry safe, and the CLI is how operators and scripts send one-off reports. The history commands let them see, and keep, what was counted.
Testing
Against a fake API:
fromquery, and the table's columns (key, limit, negative delta)..partialbehind;--from;OutsideRetentionexits 5 and creates no file.Checklist
CONTRIBUTING.md.Signed-off-byline.