Add debug log that shows up in trace when change notes are loaded

We want to see in a trace when a request triggers loading of many change
notes.

Example Log:
[2018-08-14 09:44:06,565] [HTTP-75] DEBUG com.google.gerrit.server.notedb.AbstractChangeNotes : Load change notes for change 277 of project foo from refs/changes/77/277/meta (NOTE_DB) [CONTEXT forced=true TRACE_ID="1534232646506-2d0c7a5d" ]

Change-Id: I31cbf38f6e77870db7715fba6cd51d8da173542c
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2018-08-14 09:35:26 +02:00
parent a0241a0276
commit ab47dc9238

View File

@@ -19,6 +19,7 @@ import static com.google.gerrit.server.notedb.NoteDbTable.CHANGES;
import com.google.auto.value.AutoValue;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.flogger.FluentLogger;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.metrics.Timer1;
import com.google.gerrit.reviewdb.client.Change;
@@ -42,6 +43,8 @@ import org.eclipse.jgit.lib.Repository;
/** View of contents at a single ref related to some change. * */
public abstract class AbstractChangeNotes<T> {
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
@VisibleForTesting
@Singleton
public static class Args {
@@ -145,6 +148,11 @@ public abstract class AbstractChangeNotes<T> {
if (loaded) {
return self();
}
logger.atFine().log(
"Load %s for change %s of project %s from %s (%s)",
getClass().getSimpleName(), getChangeId(), getProjectName(), getRefName(), primaryStorage);
boolean read = args.migration.readChanges();
if (!read && primaryStorage == PrimaryStorage.NOTE_DB) {
throw new OrmException("NoteDb is required to read change " + changeId);