Use generic types for Context classes in metric timers

Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: Ia28988a916ae67f7508bfebdff4b495e3762055d
This commit is contained in:
Edwin Kempin
2019-06-28 16:11:16 +02:00
parent aadd006c8c
commit d0019c4e06
12 changed files with 51 additions and 49 deletions

View File

@@ -139,7 +139,7 @@ public abstract class AbstractChangeNotes<T> {
if (args.failOnLoadForTest.get()) {
throw new StorageException("Reading from NoteDb is disabled");
}
try (Timer1.Context timer = args.metrics.readLatency.start(CHANGES);
try (Timer1.Context<NoteDbTable> timer = args.metrics.readLatency.start(CHANGES);
Repository repo = args.repoManager.openRepository(getProjectName());
// Call openHandle even if reading is disabled, to trigger
// auto-rebuilding before this object may get passed to a ChangeUpdate.

View File

@@ -187,7 +187,7 @@ class ChangeNotesParser {
walk.reset();
walk.markStart(walk.parseCommit(tip));
try (Timer1.Context timer = metrics.parseLatency.start(CHANGES)) {
try (Timer1.Context<NoteDbTable> timer = metrics.parseLatency.start(CHANGES)) {
ChangeNotesCommit commit;
while ((commit = walk.next()) != null) {
parse(commit);

View File

@@ -267,7 +267,7 @@ public class NoteDbUpdateManager implements AutoCloseable {
* @throws IOException if a storage layer error occurs.
*/
private void stage() throws IOException {
try (Timer1.Context timer = metrics.stageUpdateLatency.start(CHANGES)) {
try (Timer1.Context<NoteDbTable> timer = metrics.stageUpdateLatency.start(CHANGES)) {
if (isEmpty()) {
return;
}
@@ -302,7 +302,7 @@ public class NoteDbUpdateManager implements AutoCloseable {
executed = true;
return null;
}
try (Timer1.Context timer = metrics.updateLatency.start(CHANGES)) {
try (Timer1.Context<NoteDbTable> timer = metrics.updateLatency.start(CHANGES)) {
stage();
// ChangeUpdates must execute before ChangeDraftUpdates.
//

View File

@@ -100,25 +100,29 @@ public class Sequences {
}
public int nextAccountId() {
try (Timer2.Context timer = nextIdLatency.start(SequenceType.ACCOUNTS, false)) {
try (Timer2.Context<SequenceType, Boolean> timer =
nextIdLatency.start(SequenceType.ACCOUNTS, false)) {
return accountSeq.next();
}
}
public int nextChangeId() {
try (Timer2.Context timer = nextIdLatency.start(SequenceType.CHANGES, false)) {
try (Timer2.Context<SequenceType, Boolean> timer =
nextIdLatency.start(SequenceType.CHANGES, false)) {
return changeSeq.next();
}
}
public ImmutableList<Integer> nextChangeIds(int count) {
try (Timer2.Context timer = nextIdLatency.start(SequenceType.CHANGES, count > 1)) {
try (Timer2.Context<SequenceType, Boolean> timer =
nextIdLatency.start(SequenceType.CHANGES, count > 1)) {
return changeSeq.next(count);
}
}
public int nextGroupId() {
try (Timer2.Context timer = nextIdLatency.start(SequenceType.GROUPS, false)) {
try (Timer2.Context<SequenceType, Boolean> timer =
nextIdLatency.start(SequenceType.GROUPS, false)) {
return groupSeq.next();
}
}