satellite/metainfo/piecedeletion: add metrics for deletion requests

Change-Id: I48ad96e78dab84b9238c63d62bda679fc65c2072
This commit is contained in:
Rafael Gomes 2020-06-25 17:01:51 -03:00
parent d91cf5f4de
commit bdaabd611d
2 changed files with 13 additions and 0 deletions

View File

@ -131,6 +131,8 @@ func (combiner *Combiner) Enqueue(node storj.NodeURL, job Job) {
func (worker *worker) start(combiner *Combiner) {
// Try to add to worker pool, this may fail when we are shutting things down.
workerStarted := combiner.workers.Go(func() {
defer mon.TaskNamed("worker_start")(nil)(nil)
defer close(worker.done)
// Ensure we fail any jobs that the handler didn't handle.
defer FailPending(worker.jobs)

View File

@ -8,6 +8,7 @@ import (
"sync"
"time"
"github.com/spacemonkeygo/monkit/v3"
"go.uber.org/zap"
"storj.io/common/errs2"
@ -45,6 +46,7 @@ func NewDialer(log *zap.Logger, dialer rpc.Dialer, requestTimeout, failThreshold
// Handle tries to send the deletion requests to the specified node.
func (dialer *Dialer) Handle(ctx context.Context, node storj.NodeURL, queue Queue) {
defer mon.Task()(&ctx, node.ID.String())(nil)
defer FailPending(queue)
if dialer.recentlyFailed(ctx, node) {
@ -69,12 +71,21 @@ func (dialer *Dialer) Handle(ctx context.Context, node storj.NodeURL, queue Queu
}
jobs, ok := queue.PopAll()
// Add metrics on to the span
s := monkit.SpanFromCtx(ctx)
s.Annotate("delete jobs size", string(len(jobs)))
if !ok {
return
}
for len(jobs) > 0 {
batch, promises, rest := batchJobs(jobs, dialer.piecesPerRequest)
// Aggregation metrics
mon.IntVal("delete batch size").Observe(int64(len(batch)))
// Tracing metrics
s.Annotate("delete batch size", string(len(batch)))
jobs = rest
requestCtx, cancel := context.WithTimeout(ctx, dialer.requestTimeout)