Add metrics for NoteDb auto-rebuilding
Change-Id: Ia39ec6da3a7a984d5b311164418b548853cd71f2
This commit is contained in:
@@ -18,6 +18,7 @@ import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static com.google.gerrit.reviewdb.client.RefNames.changeMetaRef;
|
||||
import static com.google.gerrit.server.notedb.NoteDbTable.CHANGES;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Function;
|
||||
@@ -40,6 +41,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
||||
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.common.data.SubmitRecord;
|
||||
import com.google.gerrit.metrics.Timer1;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.ChangeMessage;
|
||||
@@ -593,10 +595,11 @@ public class ChangeNotes extends AbstractChangeNotes<ChangeNotes> {
|
||||
|
||||
private LoadHandle rebuildAndOpen(Repository repo, ObjectId oldId)
|
||||
throws IOException {
|
||||
try (Timer1.Context timer =
|
||||
args.metrics.autoRebuildLatency.start(CHANGES)) {
|
||||
Change.Id cid = getChangeId();
|
||||
ReviewDb db = args.db.get();
|
||||
ChangeRebuilder rebuilder = args.rebuilder.get();
|
||||
try {
|
||||
NoteDbUpdateManager manager = rebuilder.stage(db, cid);
|
||||
if (manager == null) {
|
||||
return super.openHandle(repo, oldId); // May be null in tests.
|
||||
@@ -615,6 +618,7 @@ public class ChangeNotes extends AbstractChangeNotes<ChangeNotes> {
|
||||
//
|
||||
// Parse notes from the staged result so we can return something useful
|
||||
// to the caller instead of throwing.
|
||||
args.metrics.autoRebuildFailureCount.increment(CHANGES);
|
||||
rebuildResult = checkNotNull(r);
|
||||
checkNotNull(r.newState());
|
||||
checkNotNull(r.staged());
|
||||
|
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.notedb;
|
||||
|
||||
import com.google.gerrit.metrics.Counter1;
|
||||
import com.google.gerrit.metrics.Description;
|
||||
import com.google.gerrit.metrics.Description.Units;
|
||||
import com.google.gerrit.metrics.Field;
|
||||
@@ -47,6 +48,17 @@ class NoteDbMetrics {
|
||||
*/
|
||||
final Timer1<NoteDbTable> parseLatency;
|
||||
|
||||
/**
|
||||
* Latency due to auto-rebuilding entities when out of date.
|
||||
* <p>
|
||||
* Excludes latency from reading ref to check whether the entity is up to
|
||||
* date.
|
||||
*/
|
||||
final Timer1<NoteDbTable> autoRebuildLatency;
|
||||
|
||||
/** Count of auto-rebuild attempts that failed. */
|
||||
final Counter1<NoteDbTable> autoRebuildFailureCount;
|
||||
|
||||
@Inject
|
||||
NoteDbMetrics(MetricMaker metrics) {
|
||||
Field<NoteDbTable> view = Field.ofEnum(NoteDbTable.class, "table");
|
||||
@@ -78,5 +90,18 @@ class NoteDbMetrics {
|
||||
.setCumulative()
|
||||
.setUnit(Units.MICROSECONDS),
|
||||
view);
|
||||
|
||||
autoRebuildLatency = metrics.newTimer(
|
||||
"notedb/auto_rebuild_latency",
|
||||
new Description("NoteDb auto-rebuilding latency by table")
|
||||
.setCumulative()
|
||||
.setUnit(Units.MILLISECONDS),
|
||||
view);
|
||||
|
||||
autoRebuildFailureCount = metrics.newCounter(
|
||||
"notedb/auto_rebuild_failure_count",
|
||||
new Description("NoteDb auto-rebuilding attempts that failed by table")
|
||||
.setCumulative(),
|
||||
view);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user