Merge pull request #1729 from ipfs-cluster/fix/pins-error-negative

Fix: operationtracker metrics go negative
This commit is contained in:
Hector Sanjuan 2022-07-04 20:20:13 +02:00 committed by GitHub
commit d2cbd8f910
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -89,7 +89,6 @@ func newOperation(ctx context.Context, pin api.Pin, typ OperationType, ph Phase,
ts: time.Now(),
error: "",
}
tracker.recordMetricUnsafe(op, 1)
return op
}
@ -126,7 +125,6 @@ func (op *Operation) Context() context.Context {
func (op *Operation) Cancel() {
_, span := trace.StartSpan(op.ctx, "optracker/Cancel")
op.cancel()
op.tracker.recordMetric(op, -1)
span.End()
}

View File

@ -91,6 +91,7 @@ func (opt *OperationTracker) TrackNewOperation(ctx context.Context, pin api.Pin,
}
// i.e. operations in error phase
// i.e. pin operations that need to be canceled for unpinning
op.tracker.recordMetric(op, -1)
op.Cancel() // cancel ongoing operation and replace it
}
@ -102,6 +103,7 @@ func (opt *OperationTracker) TrackNewOperation(ctx context.Context, pin api.Pin,
}
logger.Debugf("'%s' on cid '%s' has been created with phase '%s'", typ, pin.Cid, ph)
opt.operations[pin.Cid] = op2
opt.recordMetricUnsafe(op2, 1)
return op2
}