diff --git a/Documentation/metrics.txt b/Documentation/metrics.txt index 05cca187d9..901f15a332 100644 --- a/Documentation/metrics.txt +++ b/Documentation/metrics.txt @@ -53,17 +53,6 @@ objects needing finalization. * `query/query_latency`: Successful query latency, accumulated over the life of the process. -=== Queue - -The metrics below are per queue. - -* `queue//pool_size`: Current number of threads in the pool -* `queue//max_pool_size`: Maximum allowed number of threads in the pool -* `queue//active_threads`: Number of threads that are actively executing tasks -* `queue//scheduled_tasks`: Number of scheduled tasks in the queue -* `queue//total_scheduled_tasks_count`: Total number of tasks that have been scheduled -* `queue//total_completed_tasks_count`: Total number of tasks that have completed execution - === SSH sessions * `sshd/sessions/connected`: Number of currently connected SSH sessions. diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/WorkQueue.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/WorkQueue.java index a9461a41ea..2948cded02 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/git/WorkQueue.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/WorkQueue.java @@ -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; @@ -89,19 +83,17 @@ public class WorkQueue { } }; - private final MetricMaker metrics; private final ScheduledExecutorService defaultQueue; private final IdGenerator idGenerator; private final CopyOnWriteArrayList 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"); @@ -222,94 +214,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() { - @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() { - @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() { - @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() { - @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() { - @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() { - @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)); } @Override