Move code around
This commit is contained in:
parent
f884f0809f
commit
15e396ca92
@ -6,7 +6,6 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/alcionai/clues"
|
||||
@ -326,8 +325,6 @@ func (mw RetryMiddleware) getRetryDelay(
|
||||
// MetricsMiddleware aggregates per-request metrics on the events bus
|
||||
type MetricsMiddleware struct{}
|
||||
|
||||
var xmCount int64
|
||||
|
||||
const xmruHeader = "x-ms-resource-unit"
|
||||
|
||||
func (mw *MetricsMiddleware) Intercept(
|
||||
@ -365,9 +362,6 @@ func (mw *MetricsMiddleware) Intercept(
|
||||
xmrui = 1
|
||||
}
|
||||
|
||||
atomic.AddInt64(&xmCount, int64(xmrui))
|
||||
logger.Ctx(req.Context()).Info("xmcount ", xmCount)
|
||||
|
||||
countBus := count.Ctx(req.Context())
|
||||
countBus.Add(count.APICallTokensConsumed, int64(xmrui))
|
||||
|
||||
|
||||
@ -848,8 +848,8 @@ func (op *BackupOperation) persistResults(
|
||||
op.Results.ItemsRead = opStats.ctrl.Successes
|
||||
|
||||
// API stats
|
||||
apiStats := stats.GetAPIStats(op.Counter)
|
||||
op.Results.TokensConsumed = apiStats.TokensConsumed
|
||||
apiStats := getAPIStats(op.Counter)
|
||||
op.Results.APITokensConsumed = apiStats.APITokensConsumed
|
||||
|
||||
// Only return non-recoverable errors at this point.
|
||||
return op.Errors.Failure()
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -3,8 +3,6 @@ package stats
|
||||
import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/alcionai/corso/src/pkg/count"
|
||||
)
|
||||
|
||||
// ReadWrites tracks the total count of reads and writes. ItemsRead
|
||||
@ -47,15 +45,5 @@ type SkippedCounts struct {
|
||||
}
|
||||
|
||||
type APIStats struct {
|
||||
TokensConsumed int64 `json:"tokensConsumed"`
|
||||
}
|
||||
|
||||
func GetAPIStats(
|
||||
ctr *count.Bus,
|
||||
) APIStats {
|
||||
s := APIStats{}
|
||||
|
||||
s.TokensConsumed = ctr.Total(count.APICallTokensConsumed)
|
||||
|
||||
return s
|
||||
APITokensConsumed int64 `json:"apiTokensConsumed"`
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user