[#370] Add tree service metrics
All checks were successful
ci/woodpecker/push/pre-commit Pipeline was successful
All checks were successful
ci/woodpecker/push/pre-commit Pipeline was successful
Signed-off-by: Alejandro Lopez <a.lopez@yadro.com>
This commit is contained in:
parent
f2e5dead7e
commit
bc34fee6a7
9 changed files with 117 additions and 3 deletions
|
@ -75,6 +75,7 @@ func (s *Service) replicationWorker(ctx context.Context) {
|
|||
attribute.String("public_key", hex.EncodeToString(task.n.PublicKey())),
|
||||
),
|
||||
)
|
||||
start := time.Now()
|
||||
|
||||
var lastErr error
|
||||
var lastAddr string
|
||||
|
@ -113,6 +114,9 @@ func (s *Service) replicationWorker(ctx context.Context) {
|
|||
zap.String("address", lastAddr),
|
||||
zap.String("key", hex.EncodeToString(task.n.PublicKey())))
|
||||
}
|
||||
s.metrics.AddReplicateTaskDuration(time.Since(start), false)
|
||||
} else {
|
||||
s.metrics.AddReplicateTaskDuration(time.Since(start), true)
|
||||
}
|
||||
span.End()
|
||||
}
|
||||
|
@ -137,6 +141,7 @@ func (s *Service) replicateLoop(ctx context.Context) {
|
|||
case <-ctx.Done():
|
||||
return
|
||||
case op := <-s.replicateCh:
|
||||
start := time.Now()
|
||||
err := s.replicate(op)
|
||||
if err != nil {
|
||||
s.log.Error(logs.TreeErrorDuringReplication,
|
||||
|
@ -144,6 +149,7 @@ func (s *Service) replicateLoop(ctx context.Context) {
|
|||
zap.Stringer("cid", op.cid),
|
||||
zap.String("treeID", op.treeID))
|
||||
}
|
||||
s.metrics.AddReplicateWaitDuration(time.Since(start), err == nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue