summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Milanesio <luca.milanesio@gmail.com>2024-01-25 12:49:59 +0000
committerLuca Milanesio <luca.milanesio@gmail.com>2024-01-25 13:01:32 +0000
commitdb0cad716c4b176d66d45e70793c8b3d90bee96e (patch)
tree8951a9436e14acec777f363afc10d2ad7ad3a7c0
parent0ca24de06391b083b2be30a900db673b259b8c76 (diff)
Add timer for git/upload-pack/phase_negotiating
JGit packer tracks time spent in the negotiation phase. This statistic was only exposed in the sshd_log and is not available when the client uses Git/HTTP, which is counter-intuitive. Having the statistics in log files is not ideal, though, because for the Gerrit administrator, it takes more time to surface them and defining alerts or monitoring: - Logs need to be collected - Metrics extracted - Calculate the KPIs - Graph and alert based on KPIs Gerrit already has an out-of-the-box capability for tracking JGit protocol-level metrics, but did not cover until now, the negotiation phase, which is critical for an optimal Git/HTTP performance. Add the git/upload-pack/phase_negotiating so that the Gerrit admin can graph how these are performing and spot any potential issues. Release-Notes: Add timer for git/upload-pack/phase_negotiating Change-Id: If185e0a1b4a4418243a2273ec850de01337afdd8
-rw-r--r--Documentation/metrics.txt3
-rw-r--r--java/com/google/gerrit/server/git/UploadPackMetricsHook.java10
2 files changed, 13 insertions, 0 deletions
diff --git a/Documentation/metrics.txt b/Documentation/metrics.txt
index 49ac84c461..2ed2c2e23b 100644
--- a/Documentation/metrics.txt
+++ b/Documentation/metrics.txt
@@ -374,6 +374,9 @@ Each queue provides the following metrics:
* `git/upload-pack/phase_compressing`: Time spent in the 'Compressing...' phase.
** `operation`:
The name of the operation (CLONE, FETCH).
+* `git/upload-pack/phase_negotiating`: Time spent in the negotiation phase.
+** `operation`:
+ The name of the operation (CLONE, FETCH).
* `git/upload-pack/phase_writing`: Time spent transferring bytes to client.
** `operation`:
The name of the operation (CLONE, FETCH).
diff --git a/java/com/google/gerrit/server/git/UploadPackMetricsHook.java b/java/com/google/gerrit/server/git/UploadPackMetricsHook.java
index 1619addd75..e1403828b9 100644
--- a/java/com/google/gerrit/server/git/UploadPackMetricsHook.java
+++ b/java/com/google/gerrit/server/git/UploadPackMetricsHook.java
@@ -39,6 +39,7 @@ public class UploadPackMetricsHook implements PostUploadHook {
private final Counter1<Operation> requestCount;
private final Timer1<Operation> counting;
private final Timer1<Operation> compressing;
+ private final Timer1<Operation> negotiating;
private final Timer1<Operation> writing;
private final Histogram1<Operation> packBytes;
@@ -72,6 +73,14 @@ public class UploadPackMetricsHook implements PostUploadHook {
.setUnit(Units.MILLISECONDS),
operationField);
+ negotiating =
+ metricMaker.newTimer(
+ "git/upload-pack/phase_negotiating",
+ new Description("Time spent in the negotiation phase")
+ .setCumulative()
+ .setUnit(Units.MILLISECONDS),
+ operationField);
+
writing =
metricMaker.newTimer(
"git/upload-pack/phase_writing",
@@ -99,6 +108,7 @@ public class UploadPackMetricsHook implements PostUploadHook {
requestCount.increment(op);
counting.record(op, stats.getTimeCounting(), MILLISECONDS);
compressing.record(op, stats.getTimeCompressing(), MILLISECONDS);
+ negotiating.record(op, stats.getTimeNegotiating(), MILLISECONDS);
writing.record(op, stats.getTimeWriting(), MILLISECONDS);
packBytes.record(op, stats.getTotalBytes());
}