Merge changes I3b540928,I930a5711,Ib76aafb7
* changes:
ReceiveCommits: Add field with update type to push_count metric
Add metric to count pushes
Document receivecommits/ps_revision_missing metric
diff --git a/Documentation/metrics.txt b/Documentation/metrics.txt
index 0bbf4fb..36b3473 100644
--- a/Documentation/metrics.txt
+++ b/Documentation/metrics.txt
@@ -118,6 +118,15 @@
** `type`:
type of push (create/replace, autoclose, normal)
* `receivecommits/timeout`: rate of push timeouts
+* `receivecommits/ps_revision_missing`: errors due to patch set revision missing
+* `receivecommits/push_count`: number of pushes
+** `kind`:
+ The push kind (direct vs. magic).
+** `project`:
+ The name of the project for which the push is done.
+** `type`:
+ The type of the update (CREATE, UPDATE, CREATE/UPDATE, UPDATE_NONFASTFORWARD,
+ DELETE).
=== Process
diff --git a/java/com/google/gerrit/server/git/receive/ReceiveCommits.java b/java/com/google/gerrit/server/git/receive/ReceiveCommits.java
index f7f58fc..ec1a5c8 100644
--- a/java/com/google/gerrit/server/git/receive/ReceiveCommits.java
+++ b/java/com/google/gerrit/server/git/receive/ReceiveCommits.java
@@ -102,7 +102,9 @@
import com.google.gerrit.extensions.validators.CommentValidationFailure;
import com.google.gerrit.extensions.validators.CommentValidator;
import com.google.gerrit.metrics.Counter0;
+import com.google.gerrit.metrics.Counter3;
import com.google.gerrit.metrics.Description;
+import com.google.gerrit.metrics.Field;
import com.google.gerrit.metrics.MetricMaker;
import com.google.gerrit.server.CancellationMetrics;
import com.google.gerrit.server.ChangeUtil;
@@ -323,6 +325,7 @@
@Singleton
private static class Metrics {
private final Counter0 psRevisionMissing;
+ private final Counter3<String, String, String> pushCount;
@Inject
Metrics(MetricMaker metricMaker) {
@@ -330,6 +333,23 @@
metricMaker.newCounter(
"receivecommits/ps_revision_missing",
new Description("errors due to patch set revision missing"));
+ pushCount =
+ metricMaker.newCounter(
+ "receivecommits/push_count",
+ new Description("number of pushes"),
+ Field.ofString("kind", (metadataBuilder, fieldValue) -> {})
+ .description("The push kind (direct vs. magic).")
+ .build(),
+ Field.ofString(
+ "project",
+ (metadataBuilder, fieldValue) -> metadataBuilder.projectName(fieldValue))
+ .description("The name of the project for which the push is done.")
+ .build(),
+ Field.ofString("type", (metadataBuilder, fieldValue) -> {})
+ .description(
+ "The type of the update (CREATE, UPDATE, CREATE/UPDATE,"
+ + " UPDATE_NONFASTFORWARD, DELETE).")
+ .build());
}
}
@@ -727,6 +747,13 @@
return;
}
+ if (!magicCommands.isEmpty()) {
+ metrics.pushCount.increment("magic", project.getName(), getUpdateType(magicCommands));
+ }
+ if (!regularCommands.isEmpty()) {
+ metrics.pushCount.increment("direct", project.getName(), getUpdateType(regularCommands));
+ }
+
try {
if (!regularCommands.isEmpty()) {
handleRegularCommands(regularCommands, progress);
@@ -777,6 +804,15 @@
lazy(() -> commands.stream().map(ReceiveCommits::commandToString).collect(joining(","))));
}
+ private String getUpdateType(List<ReceiveCommand> commands) {
+ return commands.stream()
+ .map(ReceiveCommand::getType)
+ .map(ReceiveCommand.Type::name)
+ .distinct()
+ .sorted()
+ .collect(joining("/"));
+ }
+
private void sendErrorMessages() {
if (!errors.isEmpty()) {
logger.atFine().log("Handling error conditions: %s", errors.keySet());