Merge "Record time to load a single external ID from NoteDb"
This commit is contained in:
		@@ -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
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user