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.checkNotNull;
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static com.google.gerrit.reviewdb.client.RefNames.changeMetaRef;
|
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.annotations.VisibleForTesting;
|
||||||
import com.google.common.base.Function;
|
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.common.util.concurrent.ListeningExecutorService;
|
||||||
import com.google.gerrit.common.Nullable;
|
import com.google.gerrit.common.Nullable;
|
||||||
import com.google.gerrit.common.data.SubmitRecord;
|
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.Account;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.ChangeMessage;
|
import com.google.gerrit.reviewdb.client.ChangeMessage;
|
||||||
@@ -593,10 +595,11 @@ public class ChangeNotes extends AbstractChangeNotes<ChangeNotes> {
|
|||||||
|
|
||||||
private LoadHandle rebuildAndOpen(Repository repo, ObjectId oldId)
|
private LoadHandle rebuildAndOpen(Repository repo, ObjectId oldId)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
Change.Id cid = getChangeId();
|
try (Timer1.Context timer =
|
||||||
ReviewDb db = args.db.get();
|
args.metrics.autoRebuildLatency.start(CHANGES)) {
|
||||||
ChangeRebuilder rebuilder = args.rebuilder.get();
|
Change.Id cid = getChangeId();
|
||||||
try {
|
ReviewDb db = args.db.get();
|
||||||
|
ChangeRebuilder rebuilder = args.rebuilder.get();
|
||||||
NoteDbUpdateManager manager = rebuilder.stage(db, cid);
|
NoteDbUpdateManager manager = rebuilder.stage(db, cid);
|
||||||
if (manager == null) {
|
if (manager == null) {
|
||||||
return super.openHandle(repo, oldId); // May be null in tests.
|
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
|
// Parse notes from the staged result so we can return something useful
|
||||||
// to the caller instead of throwing.
|
// to the caller instead of throwing.
|
||||||
|
args.metrics.autoRebuildFailureCount.increment(CHANGES);
|
||||||
rebuildResult = checkNotNull(r);
|
rebuildResult = checkNotNull(r);
|
||||||
checkNotNull(r.newState());
|
checkNotNull(r.newState());
|
||||||
checkNotNull(r.staged());
|
checkNotNull(r.staged());
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.notedb;
|
package com.google.gerrit.server.notedb;
|
||||||
|
|
||||||
|
import com.google.gerrit.metrics.Counter1;
|
||||||
import com.google.gerrit.metrics.Description;
|
import com.google.gerrit.metrics.Description;
|
||||||
import com.google.gerrit.metrics.Description.Units;
|
import com.google.gerrit.metrics.Description.Units;
|
||||||
import com.google.gerrit.metrics.Field;
|
import com.google.gerrit.metrics.Field;
|
||||||
@@ -47,6 +48,17 @@ class NoteDbMetrics {
|
|||||||
*/
|
*/
|
||||||
final Timer1<NoteDbTable> parseLatency;
|
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
|
@Inject
|
||||||
NoteDbMetrics(MetricMaker metrics) {
|
NoteDbMetrics(MetricMaker metrics) {
|
||||||
Field<NoteDbTable> view = Field.ofEnum(NoteDbTable.class, "table");
|
Field<NoteDbTable> view = Field.ofEnum(NoteDbTable.class, "table");
|
||||||
@@ -78,5 +90,18 @@ class NoteDbMetrics {
|
|||||||
.setCumulative()
|
.setCumulative()
|
||||||
.setUnit(Units.MICROSECONDS),
|
.setUnit(Units.MICROSECONDS),
|
||||||
view);
|
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