Merge branch 'stable-2.14' into stable-2.15

* stable-2.14:
  Revert "WorkQueue: Add metrics"

Change-Id: I29c71499808a73582f60a697c22863ab04390751
This commit is contained in:
David Pursehouse 2018-05-23 09:36:13 +09:00
commit 54030c7e3d
2 changed files with 3 additions and 110 deletions

View File

@ -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/<queueName>/pool_size`: Current number of threads in the pool
* `queue/<queueName>/max_pool_size`: Maximum allowed number of threads in the pool
* `queue/<queueName>/active_threads`: Number of threads that are actively executing tasks
* `queue/<queueName>/scheduled_tasks`: Number of scheduled tasks in the queue
* `queue/<queueName>/total_scheduled_tasks_count`: Total number of tasks that have been scheduled
* `queue/<queueName>/total_completed_tasks_count`: Total number of tasks that have completed execution
=== SSH sessions
* `sshd/sessions/connected`: Number of currently connected SSH sessions.

View File

@ -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<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");
@ -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<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));
}
@Override