Compare commits

...

3 Commits

Author SHA1 Message Date
Abhishek Pandey
15e396ca92 Move code around 2023-10-23 22:44:18 -07:00
Abhishek Pandey
f884f0809f Remove per minute count 2023-10-23 22:44:18 -07:00
Abhishek Pandey
9aad0aa428 Add initial stats 2023-10-23 22:43:37 -07:00
5 changed files with 24 additions and 1 deletions

View File

@ -214,6 +214,8 @@ func genericCreateCommand(
continue
}
logger.Ctx(ictx).Infow("graph api stats", "stats", bo.Results.APIStats)
bIDs = append(bIDs, string(bo.Results.BackupID))
if !DisplayJSONFormat() {

View File

@ -70,6 +70,7 @@ type BackupResults struct {
BackupID model.StableID `json:"backupID"`
// keys are found in /pkg/count/keys.go
Counts map[string]int64 `json:"counts"`
stats.APIStats
}
// NewBackupOperation constructs and validates a backup operation.
@ -846,6 +847,10 @@ func (op *BackupOperation) persistResults(
op.Results.ItemsRead = opStats.ctrl.Successes
// API stats
apiStats := getAPIStats(op.Counter)
op.Results.APITokensConsumed = apiStats.APITokensConsumed
// Only return non-recoverable errors at this point.
return op.Errors.Failure()
}

View File

@ -6,9 +6,11 @@ import (
"github.com/alcionai/clues"
"github.com/alcionai/corso/src/internal/model"
"github.com/alcionai/corso/src/internal/stats"
"github.com/alcionai/corso/src/internal/streamstore"
"github.com/alcionai/corso/src/pkg/backup"
"github.com/alcionai/corso/src/pkg/backup/details"
"github.com/alcionai/corso/src/pkg/count"
"github.com/alcionai/corso/src/pkg/fault"
"github.com/alcionai/corso/src/pkg/store"
)
@ -59,3 +61,12 @@ func getDetailsFromBackup(
return &deets, nil
}
func getAPIStats(
ctr *count.Bus,
) stats.APIStats {
s := stats.APIStats{}
s.APITokensConsumed = ctr.Total(count.APICallTokensConsumed)
return s
}

View File

@ -43,3 +43,7 @@ type SkippedCounts struct {
SkippedMalware int `json:"skippedMalware"`
SkippedInvalidOneNoteFile int `json:"skippedInvalidOneNoteFile"`
}
type APIStats struct {
APITokensConsumed int64 `json:"apiTokensConsumed"`
}

View File

@ -4,7 +4,8 @@ type key string
const (
// count of bucket-tokens consumed by api calls.
APICallTokensConsumed key = "api-call-tokens-consumed"
APICallTokensConsumed key = "api-call-tokens-consumed"
PeakAPITokenUsagePerMin key = "peak-api-token-usage-per-min"
// count of api calls that resulted in failure due to throttling.
ThrottledAPICalls key = "throttled-api-calls"
)