Add a success and attempt metric for cross-project topic submissions.
Change-Id: Ice704290224064bca9f3389bec7419c21054baa0
This commit is contained in:
parent
18962aa2b5
commit
61f6565591
|
@ -63,6 +63,12 @@ of the process.
|
|||
|
||||
* `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/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.ResourceNotFoundException;
|
||||
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.Branch;
|
||||
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.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import java.io.IOException;
|
||||
import java.sql.Timestamp;
|
||||
|
@ -235,6 +239,7 @@ public class MergeOp implements AutoCloseable {
|
|||
private ListMultimap<RecipientType, Account.Id> accountsToNotify;
|
||||
private Set<Project.NameKey> allProjects;
|
||||
private boolean dryrun;
|
||||
private TopicMetrics topicMetrics;
|
||||
|
||||
@Inject
|
||||
MergeOp(
|
||||
|
@ -247,6 +252,7 @@ public class MergeOp implements AutoCloseable {
|
|||
SubmoduleOp.Factory subOpFactory,
|
||||
MergeOpRepoManager orm,
|
||||
NotifyUtil notifyUtil,
|
||||
TopicMetrics topicMetrics,
|
||||
@Assisted BatchUpdate.Factory batchUpdateFactory) {
|
||||
this.cmUtil = cmUtil;
|
||||
this.internalUserFactory = internalUserFactory;
|
||||
|
@ -258,6 +264,7 @@ public class MergeOp implements AutoCloseable {
|
|||
this.orm = orm;
|
||||
this.notifyUtil = notifyUtil;
|
||||
this.batchUpdateFactory = batchUpdateFactory;
|
||||
this.topicMetrics = topicMetrics;
|
||||
}
|
||||
|
||||
@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 {
|
||||
checkArgument(!cs.furtherHiddenChanges(), "cannot integrate hidden changes into history");
|
||||
logDebug("Beginning merge attempt on {}", cs);
|
||||
|
@ -457,14 +483,25 @@ public class MergeOp implements AutoCloseable {
|
|||
throw new IntegrationException("Error reading changes to submit", e);
|
||||
}
|
||||
Set<Branch.NameKey> branches = cbb.keySet();
|
||||
|
||||
int projects = 0;
|
||||
for (Branch.NameKey branch : branches) {
|
||||
OpenRepo or = openRepo(branch.getParentKey());
|
||||
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.
|
||||
commitStatus.maybeFailVerbose();
|
||||
|
||||
if (projects > 1) {
|
||||
topicMetrics.topicSubmissions.increment();
|
||||
}
|
||||
try {
|
||||
SubmoduleOp submoduleOp = subOpFactory.create(branches, orm);
|
||||
List<SubmitStrategy> strategies = getSubmitStrategies(toSubmit, submoduleOp, dryrun);
|
||||
|
@ -494,6 +531,10 @@ public class MergeOp implements AutoCloseable {
|
|||
}
|
||||
throw new IntegrationException(msg, e);
|
||||
}
|
||||
|
||||
if (projects > 1) {
|
||||
topicMetrics.topicSubmissionsCompleted.increment();
|
||||
}
|
||||
}
|
||||
|
||||
public Set<Project.NameKey> getAllProjects() {
|
||||
|
|
Loading…
Reference in New Issue