fix panic
This commit is contained in:
parent
31c435af16
commit
4c4dcf46be
@ -12,8 +12,10 @@ import (
|
||||
. "github.com/alcionai/corso/src/cli/print"
|
||||
"github.com/alcionai/corso/src/cli/utils"
|
||||
"github.com/alcionai/corso/src/internal/data"
|
||||
"github.com/alcionai/corso/src/internal/events"
|
||||
"github.com/alcionai/corso/src/pkg/backup/details"
|
||||
"github.com/alcionai/corso/src/pkg/fault"
|
||||
"github.com/alcionai/corso/src/pkg/logger"
|
||||
"github.com/alcionai/corso/src/pkg/path"
|
||||
"github.com/alcionai/corso/src/pkg/repository"
|
||||
"github.com/alcionai/corso/src/pkg/selectors"
|
||||
@ -139,6 +141,9 @@ func createOneDriveCmd(cmd *cobra.Command, args []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
ctx, flushMetrics := events.NewMetrics(ctx, logger.Writer{Ctx: ctx})
|
||||
defer flushMetrics()
|
||||
|
||||
r, acct, err := utils.AccountConnectAndWriteRepoConfig(
|
||||
ctx,
|
||||
cmd,
|
||||
|
||||
@ -49,6 +49,10 @@ func NewCollector(mp metric.MeterProvider) {
|
||||
for _, key := range metricKeys {
|
||||
data[key], _ = rmc.meter.Int64Counter(key)
|
||||
}
|
||||
|
||||
// // Create a new guage
|
||||
// g, _ := rmc.meter.Int64ObservableGauge(RLTokens)
|
||||
|
||||
}
|
||||
|
||||
func NewMetrics(ctx context.Context, w io.Writer) (context.Context, func()) {
|
||||
@ -61,13 +65,13 @@ func NewMetrics(ctx context.Context, w io.Writer) (context.Context, func()) {
|
||||
// Inc increments the given category by 1.
|
||||
func Inc(ctx context.Context, cat string) {
|
||||
ctr := data[cat]
|
||||
ctr.Add(context.Background(), 1)
|
||||
ctr.Add(ctx, 1)
|
||||
}
|
||||
|
||||
// IncN increments the given category by N.
|
||||
func IncN(ctx context.Context, n int, cat string) {
|
||||
ctr := data[cat]
|
||||
ctr.Add(context.Background(), int64(n))
|
||||
ctr.Add(ctx, int64(n))
|
||||
}
|
||||
|
||||
// func (rmc *collector) RegisterMetricsClient(ctx context.Context) {
|
||||
|
||||
@ -199,8 +199,8 @@ func (op *BackupOperation) Run(ctx context.Context) (err error) {
|
||||
end()
|
||||
}()
|
||||
|
||||
ctx, flushMetrics := events.NewMetrics(ctx, logger.Writer{Ctx: ctx})
|
||||
defer flushMetrics()
|
||||
// ctx, flushMetrics := events.NewMetrics(ctx, logger.Writer{Ctx: ctx})
|
||||
// defer flushMetrics()
|
||||
|
||||
ctx = count.Embed(ctx, op.Counter)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user