Revert "WorkQueue: Add metrics"
Some plugins are creating a work queue on load which will create the metrics for that queue. If plugin is reloaded, the work queue is created again and it will try to create metrics again which will fail because metrics already exists thus causing the plugin to not load. This reverts commitfe270ddd54. This reverts commit4e97e35b7c. This reverts commitfccd70ed65. This reverts commiteb2f45c84e. Change-Id: I0cef3831470d919c8efea4c019943af69a85281e
This commit is contained in:
committed by
David Pursehouse
parent
5872780a5a
commit
b801a36775
@@ -14,14 +14,8 @@
|
||||
|
||||
package com.google.gerrit.server.git;
|
||||
|
||||
import static com.google.gerrit.metrics.dropwizard.DropWizardMetricMaker.sanitizeMetricName;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.gerrit.extensions.events.LifecycleListener;
|
||||
import com.google.gerrit.lifecycle.LifecycleModule;
|
||||
import com.google.gerrit.metrics.Description;
|
||||
import com.google.gerrit.metrics.MetricMaker;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.server.config.GerritServerConfig;
|
||||
import com.google.gerrit.server.util.IdGenerator;
|
||||
@@ -88,19 +82,17 @@ public class WorkQueue {
|
||||
}
|
||||
};
|
||||
|
||||
private final MetricMaker metrics;
|
||||
private final Executor defaultQueue;
|
||||
private final IdGenerator idGenerator;
|
||||
private final CopyOnWriteArrayList<Executor> queues;
|
||||
|
||||
@Inject
|
||||
WorkQueue(MetricMaker metrics, IdGenerator idGenerator, @GerritServerConfig Config cfg) {
|
||||
this(metrics, idGenerator, cfg.getInt("execution", "defaultThreadPoolSize", 1));
|
||||
WorkQueue(IdGenerator idGenerator, @GerritServerConfig Config cfg) {
|
||||
this(idGenerator, cfg.getInt("execution", "defaultThreadPoolSize", 1));
|
||||
}
|
||||
|
||||
/** Constructor to allow binding the WorkQueue more explicitly in a vhost setup. */
|
||||
public WorkQueue(MetricMaker metrics, IdGenerator idGenerator, int defaultThreadPoolSize) {
|
||||
this.metrics = metrics;
|
||||
public WorkQueue(IdGenerator idGenerator, int defaultThreadPoolSize) {
|
||||
this.idGenerator = idGenerator;
|
||||
this.queues = new CopyOnWriteArrayList<>();
|
||||
this.defaultQueue = createQueue(defaultThreadPoolSize, "WorkQueue");
|
||||
@@ -207,94 +199,6 @@ public class WorkQueue {
|
||||
corePoolSize + 4 // concurrency level
|
||||
);
|
||||
queueName = prefix;
|
||||
try {
|
||||
buildMetrics(queueName);
|
||||
} catch (IllegalArgumentException e) {
|
||||
if (e.getMessage().contains("already")) {
|
||||
log.warn("Not creating metrics for queue '{}': already exists", queueName);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buildMetrics(String queueName) {
|
||||
metrics.newCallbackMetric(
|
||||
getMetricName(queueName, "max_pool_size"),
|
||||
Long.class,
|
||||
new Description("Maximum allowed number of threads in the pool")
|
||||
.setGauge()
|
||||
.setUnit("threads"),
|
||||
new Supplier<Long>() {
|
||||
@Override
|
||||
public Long get() {
|
||||
return (long) getMaximumPoolSize();
|
||||
}
|
||||
});
|
||||
metrics.newCallbackMetric(
|
||||
getMetricName(queueName, "pool_size"),
|
||||
Long.class,
|
||||
new Description("Current number of threads in the pool").setGauge().setUnit("threads"),
|
||||
new Supplier<Long>() {
|
||||
@Override
|
||||
public Long get() {
|
||||
return (long) getPoolSize();
|
||||
}
|
||||
});
|
||||
metrics.newCallbackMetric(
|
||||
getMetricName(queueName, "active_threads"),
|
||||
Long.class,
|
||||
new Description("Number number of threads that are actively executing tasks")
|
||||
.setGauge()
|
||||
.setUnit("threads"),
|
||||
new Supplier<Long>() {
|
||||
@Override
|
||||
public Long get() {
|
||||
return (long) getActiveCount();
|
||||
}
|
||||
});
|
||||
metrics.newCallbackMetric(
|
||||
getMetricName(queueName, "scheduled_tasks"),
|
||||
Integer.class,
|
||||
new Description("Number of scheduled tasks in the queue").setGauge().setUnit("tasks"),
|
||||
new Supplier<Integer>() {
|
||||
@Override
|
||||
public Integer get() {
|
||||
return getQueue().size();
|
||||
}
|
||||
});
|
||||
metrics.newCallbackMetric(
|
||||
getMetricName(queueName, "total_scheduled_tasks_count"),
|
||||
Long.class,
|
||||
new Description("Total number of tasks that have been scheduled for execution")
|
||||
.setCumulative()
|
||||
.setUnit("tasks"),
|
||||
new Supplier<Long>() {
|
||||
@Override
|
||||
public Long get() {
|
||||
return (long) getTaskCount();
|
||||
}
|
||||
});
|
||||
metrics.newCallbackMetric(
|
||||
getMetricName(queueName, "total_completed_tasks_count"),
|
||||
Long.class,
|
||||
new Description("Total number of tasks that have completed execution")
|
||||
.setCumulative()
|
||||
.setUnit("tasks"),
|
||||
new Supplier<Long>() {
|
||||
@Override
|
||||
public Long get() {
|
||||
return (long) getCompletedTaskCount();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private String getMetricName(String queueName, String metricName) {
|
||||
String name =
|
||||
CaseFormat.UPPER_CAMEL.to(
|
||||
CaseFormat.LOWER_UNDERSCORE,
|
||||
queueName.replaceFirst("SSH", "Ssh").replaceAll("-", ""));
|
||||
return sanitizeMetricName(String.format("queue/%s/%s", name, metricName));
|
||||
}
|
||||
|
||||
public void unregisterWorkQueue() {
|
||||
|
||||
Reference in New Issue
Block a user