Line data Source code
1 : // Copyright (C) 2016 The Android Open Source Project 2 : // 3 : // Licensed under the Apache License, Version 2.0 (the "License"); 4 : // you may not use this file except in compliance with the License. 5 : // You may obtain a copy of the License at 6 : // 7 : // http://www.apache.org/licenses/LICENSE-2.0 8 : // 9 : // Unless required by applicable law or agreed to in writing, software 10 : // distributed under the License is distributed on an "AS IS" BASIS, 11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 : // See the License for the specific language governing permissions and 13 : // limitations under the License. 14 : 15 : package com.google.gerrit.server.notedb; 16 : 17 : import com.google.gerrit.metrics.Description; 18 : import com.google.gerrit.metrics.Description.Units; 19 : import com.google.gerrit.metrics.MetricMaker; 20 : import com.google.gerrit.metrics.Timer0; 21 : import com.google.inject.Inject; 22 : import com.google.inject.Singleton; 23 : 24 : /** Metrics for accessing and updating changes in NoteDb. */ 25 : @Singleton 26 : class NoteDbMetrics { 27 : /** End-to-end latency for writing a collection of updates. */ 28 : final Timer0 updateLatency; 29 : 30 : /** 31 : * The portion of {@link #updateLatency} due to preparing the sequence of updates. 32 : * 33 : * <p>May include some I/O (e.g. reading old refs), but excludes writes. 34 : */ 35 : final Timer0 stageUpdateLatency; 36 : 37 : /** End-to-end latency for reading changes from NoteDb, including reading ref(s) and parsing. */ 38 : final Timer0 readLatency; 39 : 40 : /** 41 : * The portion of {@link #readLatency} due to parsing commits, but excluding I/O (to a best 42 : * effort). 43 : */ 44 : final Timer0 parseLatency; 45 : 46 : @Inject 47 152 : NoteDbMetrics(MetricMaker metrics) { 48 152 : updateLatency = 49 152 : metrics.newTimer( 50 : "notedb/update_latency", 51 : new Description("NoteDb update latency for changes") 52 152 : .setCumulative() 53 152 : .setUnit(Units.MILLISECONDS)); 54 : 55 152 : stageUpdateLatency = 56 152 : metrics.newTimer( 57 : "notedb/stage_update_latency", 58 : new Description("Latency for staging change updates to NoteDb") 59 152 : .setCumulative() 60 152 : .setUnit(Units.MICROSECONDS)); 61 : 62 152 : readLatency = 63 152 : metrics.newTimer( 64 : "notedb/read_latency", 65 : new Description("NoteDb read latency for changes") 66 152 : .setCumulative() 67 152 : .setUnit(Units.MILLISECONDS)); 68 : 69 152 : parseLatency = 70 152 : metrics.newTimer( 71 : "notedb/parse_latency", 72 : new Description("NoteDb parse latency for changes") 73 152 : .setCumulative() 74 152 : .setUnit(Units.MICROSECONDS)); 75 152 : } 76 : }