Record time to load a single external ID from NoteDb

This commit adds a new timer to track loading a single external ID from
NoteDb. The measurement will be used to decide on any improvements to
this space.

Change-Id: I86680bf1cd1a59000a39efa60667c27e753105a5
This commit is contained in:
Patrick Hiesel
2020-01-28 15:29:48 +01:00
parent 5a09d9881c
commit fd80675e12
2 changed files with 13 additions and 2 deletions

View File

@@ -152,6 +152,8 @@ excluding reindexing
* `notedb/external_id_update_count`: Total number of external ID updates.
* `notedb/read_all_external_ids_latency`: Latency for reading all
external ID's from NoteDb.
* `notedb/read_singke_external_id_latency`: Latency for reading a single
external ID from NoteDb.
=== Permissions

View File

@@ -68,6 +68,7 @@ public class ExternalIdReader {
private final AllUsersName allUsersName;
private boolean failOnLoad = false;
private final Timer0 readAllLatency;
private final Timer0 readSingleLatency;
@Inject
ExternalIdReader(
@@ -80,6 +81,12 @@ public class ExternalIdReader {
new Description("Latency for reading all external IDs from NoteDb.")
.setCumulative()
.setUnit(Units.MILLISECONDS));
this.readSingleLatency =
metricMaker.newTimer(
"notedb/read_single_external_id_latency",
new Description("Latency for reading a single external ID from NoteDb.")
.setCumulative()
.setUnit(Units.MILLISECONDS));
}
@VisibleForTesting
@@ -126,7 +133,8 @@ public class ExternalIdReader {
Optional<ExternalId> get(ExternalId.Key key) throws IOException, ConfigInvalidException {
checkReadEnabled();
try (Repository repo = repoManager.openRepository(allUsersName)) {
try (Timer0.Context ctx = readSingleLatency.start();
Repository repo = repoManager.openRepository(allUsersName)) {
return ExternalIdNotes.loadReadOnly(allUsersName, repo).get(key);
}
}
@@ -136,7 +144,8 @@ public class ExternalIdReader {
throws IOException, ConfigInvalidException {
checkReadEnabled();
try (Repository repo = repoManager.openRepository(allUsersName)) {
try (Timer0.Context ctx = readSingleLatency.start();
Repository repo = repoManager.openRepository(allUsersName)) {
return ExternalIdNotes.loadReadOnly(allUsersName, repo, rev).get(key);
}
}