Add a success and attempt metric for cross-project topic submissions.
Change-Id: Ice704290224064bca9f3389bec7419c21054baa0
This commit is contained in:
@@ -63,6 +63,12 @@ of the process.
|
|||||||
|
|
||||||
* `sql/connection_pool/connections`: SQL database connections.
|
* `sql/connection_pool/connections`: SQL database connections.
|
||||||
|
|
||||||
|
=== Topics
|
||||||
|
|
||||||
|
* `topic/cross_project_submit`: number of cross-project topic submissions.
|
||||||
|
* `topic/cross_project_submit_completed`: number of cross-project
|
||||||
|
topic submissions that concluded successfully.
|
||||||
|
|
||||||
=== JGit
|
=== JGit
|
||||||
|
|
||||||
* `jgit/block_cache/cache_used`: Bytes of memory retained in JGit block cache.
|
* `jgit/block_cache/cache_used`: Bytes of memory retained in JGit block cache.
|
||||||
|
@@ -40,6 +40,9 @@ import com.google.gerrit.extensions.restapi.AuthException;
|
|||||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||||
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||||
|
import com.google.gerrit.metrics.Counter0;
|
||||||
|
import com.google.gerrit.metrics.Description;
|
||||||
|
import com.google.gerrit.metrics.MetricMaker;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
import com.google.gerrit.reviewdb.client.Branch;
|
import com.google.gerrit.reviewdb.client.Branch;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
@@ -70,6 +73,7 @@ import com.google.gerrit.server.update.UpdateException;
|
|||||||
import com.google.gerrit.server.util.RequestId;
|
import com.google.gerrit.server.util.RequestId;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
import com.google.inject.Singleton;
|
||||||
import com.google.inject.assistedinject.Assisted;
|
import com.google.inject.assistedinject.Assisted;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
@@ -235,6 +239,7 @@ public class MergeOp implements AutoCloseable {
|
|||||||
private ListMultimap<RecipientType, Account.Id> accountsToNotify;
|
private ListMultimap<RecipientType, Account.Id> accountsToNotify;
|
||||||
private Set<Project.NameKey> allProjects;
|
private Set<Project.NameKey> allProjects;
|
||||||
private boolean dryrun;
|
private boolean dryrun;
|
||||||
|
private TopicMetrics topicMetrics;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
MergeOp(
|
MergeOp(
|
||||||
@@ -247,6 +252,7 @@ public class MergeOp implements AutoCloseable {
|
|||||||
SubmoduleOp.Factory subOpFactory,
|
SubmoduleOp.Factory subOpFactory,
|
||||||
MergeOpRepoManager orm,
|
MergeOpRepoManager orm,
|
||||||
NotifyUtil notifyUtil,
|
NotifyUtil notifyUtil,
|
||||||
|
TopicMetrics topicMetrics,
|
||||||
@Assisted BatchUpdate.Factory batchUpdateFactory) {
|
@Assisted BatchUpdate.Factory batchUpdateFactory) {
|
||||||
this.cmUtil = cmUtil;
|
this.cmUtil = cmUtil;
|
||||||
this.internalUserFactory = internalUserFactory;
|
this.internalUserFactory = internalUserFactory;
|
||||||
@@ -258,6 +264,7 @@ public class MergeOp implements AutoCloseable {
|
|||||||
this.orm = orm;
|
this.orm = orm;
|
||||||
this.notifyUtil = notifyUtil;
|
this.notifyUtil = notifyUtil;
|
||||||
this.batchUpdateFactory = batchUpdateFactory;
|
this.batchUpdateFactory = batchUpdateFactory;
|
||||||
|
this.topicMetrics = topicMetrics;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -445,6 +452,25 @@ public class MergeOp implements AutoCloseable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
private static class TopicMetrics {
|
||||||
|
final Counter0 topicSubmissions;
|
||||||
|
final Counter0 topicSubmissionsCompleted;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
TopicMetrics(MetricMaker metrics) {
|
||||||
|
topicSubmissions =
|
||||||
|
metrics.newCounter(
|
||||||
|
"topic/cross_project_submit",
|
||||||
|
new Description("Attempts at cross project topic submission").setRate());
|
||||||
|
topicSubmissionsCompleted =
|
||||||
|
metrics.newCounter(
|
||||||
|
"topic/cross_project_submit_completed",
|
||||||
|
new Description("Cross project topic submissions that concluded successfully")
|
||||||
|
.setRate());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void integrateIntoHistory(ChangeSet cs) throws IntegrationException, RestApiException {
|
private void integrateIntoHistory(ChangeSet cs) throws IntegrationException, RestApiException {
|
||||||
checkArgument(!cs.furtherHiddenChanges(), "cannot integrate hidden changes into history");
|
checkArgument(!cs.furtherHiddenChanges(), "cannot integrate hidden changes into history");
|
||||||
logDebug("Beginning merge attempt on {}", cs);
|
logDebug("Beginning merge attempt on {}", cs);
|
||||||
@@ -457,14 +483,25 @@ public class MergeOp implements AutoCloseable {
|
|||||||
throw new IntegrationException("Error reading changes to submit", e);
|
throw new IntegrationException("Error reading changes to submit", e);
|
||||||
}
|
}
|
||||||
Set<Branch.NameKey> branches = cbb.keySet();
|
Set<Branch.NameKey> branches = cbb.keySet();
|
||||||
|
|
||||||
|
int projects = 0;
|
||||||
for (Branch.NameKey branch : branches) {
|
for (Branch.NameKey branch : branches) {
|
||||||
OpenRepo or = openRepo(branch.getParentKey());
|
OpenRepo or = openRepo(branch.getParentKey());
|
||||||
if (or != null) {
|
if (or != null) {
|
||||||
toSubmit.put(branch, validateChangeList(or, cbb.get(branch)));
|
BranchBatch bb = validateChangeList(or, cbb.get(branch));
|
||||||
|
toSubmit.put(branch, bb);
|
||||||
|
if (!bb.commits().isEmpty()) {
|
||||||
|
projects++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Done checks that don't involve running submit strategies.
|
// Done checks that don't involve running submit strategies.
|
||||||
commitStatus.maybeFailVerbose();
|
commitStatus.maybeFailVerbose();
|
||||||
|
|
||||||
|
if (projects > 1) {
|
||||||
|
topicMetrics.topicSubmissions.increment();
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
SubmoduleOp submoduleOp = subOpFactory.create(branches, orm);
|
SubmoduleOp submoduleOp = subOpFactory.create(branches, orm);
|
||||||
List<SubmitStrategy> strategies = getSubmitStrategies(toSubmit, submoduleOp, dryrun);
|
List<SubmitStrategy> strategies = getSubmitStrategies(toSubmit, submoduleOp, dryrun);
|
||||||
@@ -494,6 +531,10 @@ public class MergeOp implements AutoCloseable {
|
|||||||
}
|
}
|
||||||
throw new IntegrationException(msg, e);
|
throw new IntegrationException(msg, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (projects > 1) {
|
||||||
|
topicMetrics.topicSubmissionsCompleted.increment();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Project.NameKey> getAllProjects() {
|
public Set<Project.NameKey> getAllProjects() {
|
||||||
|
Reference in New Issue
Block a user