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/print"
|
||||||
"github.com/alcionai/corso/src/cli/utils"
|
"github.com/alcionai/corso/src/cli/utils"
|
||||||
"github.com/alcionai/corso/src/internal/data"
|
"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/backup/details"
|
||||||
"github.com/alcionai/corso/src/pkg/fault"
|
"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/path"
|
||||||
"github.com/alcionai/corso/src/pkg/repository"
|
"github.com/alcionai/corso/src/pkg/repository"
|
||||||
"github.com/alcionai/corso/src/pkg/selectors"
|
"github.com/alcionai/corso/src/pkg/selectors"
|
||||||
@ -139,6 +141,9 @@ func createOneDriveCmd(cmd *cobra.Command, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx, flushMetrics := events.NewMetrics(ctx, logger.Writer{Ctx: ctx})
|
||||||
|
defer flushMetrics()
|
||||||
|
|
||||||
r, acct, err := utils.AccountConnectAndWriteRepoConfig(
|
r, acct, err := utils.AccountConnectAndWriteRepoConfig(
|
||||||
ctx,
|
ctx,
|
||||||
cmd,
|
cmd,
|
||||||
|
|||||||
@ -49,6 +49,10 @@ func NewCollector(mp metric.MeterProvider) {
|
|||||||
for _, key := range metricKeys {
|
for _, key := range metricKeys {
|
||||||
data[key], _ = rmc.meter.Int64Counter(key)
|
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()) {
|
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.
|
// Inc increments the given category by 1.
|
||||||
func Inc(ctx context.Context, cat string) {
|
func Inc(ctx context.Context, cat string) {
|
||||||
ctr := data[cat]
|
ctr := data[cat]
|
||||||
ctr.Add(context.Background(), 1)
|
ctr.Add(ctx, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IncN increments the given category by N.
|
// IncN increments the given category by N.
|
||||||
func IncN(ctx context.Context, n int, cat string) {
|
func IncN(ctx context.Context, n int, cat string) {
|
||||||
ctr := data[cat]
|
ctr := data[cat]
|
||||||
ctr.Add(context.Background(), int64(n))
|
ctr.Add(ctx, int64(n))
|
||||||
}
|
}
|
||||||
|
|
||||||
// func (rmc *collector) RegisterMetricsClient(ctx context.Context) {
|
// func (rmc *collector) RegisterMetricsClient(ctx context.Context) {
|
||||||
|
|||||||
@ -199,8 +199,8 @@ func (op *BackupOperation) Run(ctx context.Context) (err error) {
|
|||||||
end()
|
end()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
ctx, flushMetrics := events.NewMetrics(ctx, logger.Writer{Ctx: ctx})
|
// ctx, flushMetrics := events.NewMetrics(ctx, logger.Writer{Ctx: ctx})
|
||||||
defer flushMetrics()
|
// defer flushMetrics()
|
||||||
|
|
||||||
ctx = count.Embed(ctx, op.Counter)
|
ctx = count.Embed(ctx, op.Counter)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user