Skip to content

Commit

Permalink
beano wanted metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
David Cooke committed Aug 13, 2021
1 parent ef1b5a9 commit a7a4ba9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ allprojects {
apply plugin: 'jacoco'

group = 'uk.co.ractf'
version = '0.0.70'
version = '0.0.71'

repositories {
maven { url "https://repo1.maven.org/maven2/" }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package uk.co.ractf.polaris.controller.metrics;

import com.codahale.metrics.Meter;
import com.codahale.metrics.Metric;
import com.codahale.metrics.MetricSet;
import com.codahale.metrics.Timer;
import com.codahale.metrics.*;
import com.google.inject.Inject;
import uk.co.ractf.polaris.state.ClusterState;

Expand All @@ -25,6 +22,7 @@ public Map<String, Metric> getMetrics() {
metrics.put("tasks.count", new TasksGauge(clusterState));
metrics.put("hosts.count", new HostsGauge(clusterState));
metrics.put("instances.count", new InstancesGauge(clusterState));
metrics.put("instances.total", new Counter());
metrics.put("pods.count", new PodsGauge(clusterState));

metrics.put("resources.memory.allocated", new MemoryAllocatedGauge(clusterState));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package uk.co.ractf.polaris.node.runner.docker;

import com.codahale.metrics.Counter;
import com.codahale.metrics.MetricFilter;
import com.codahale.metrics.MetricRegistry;
import com.github.dockerjava.api.DockerClient;
import com.github.dockerjava.api.command.PullImageResultCallback;
import com.github.dockerjava.api.model.*;
Expand Down Expand Up @@ -36,6 +39,8 @@ public class DockerRunner implements Runner<Container> {
private final ClusterState state;
private final AuthConfigFactory authConfigFactory;
private final NotificationFacade notifications;
private final MetricRegistry metricRegistry;
private Counter containerCounter;

private final Set<String> images = new ConcurrentSkipListSet<>();
private final Set<String> downloadingImages = new ConcurrentSkipListSet<>();
Expand All @@ -46,12 +51,14 @@ public class DockerRunner implements Runner<Container> {

@Inject
public DockerRunner(final DockerClient dockerClient, final Node node, final ClusterState state,
final AuthConfigFactory authConfigFactory, final NotificationFacade notifications) {
final AuthConfigFactory authConfigFactory, final NotificationFacade notifications,
final MetricRegistry metricRegistry) {
this.dockerClient = dockerClient;
this.node = node;
this.state = state;
this.authConfigFactory = authConfigFactory;
this.notifications = notifications;
this.metricRegistry = metricRegistry;
}

private Capability[] createCapabilityArray(final List<String> capabilities) {
Expand Down Expand Up @@ -112,6 +119,10 @@ public void startPod(final Task task, final Container container, final Instance
return;
}
try {
if (containerCounter == null) {
containerCounter = metricRegistry.getCounters(MetricFilter.startsWith("polaris")).get("polaris.instances.total");
}
containerCounter.inc();
log.info("starting {}", instance.getId());
startingContainers.add(container.getId() + instance.getId());

Expand Down

0 comments on commit a7a4ba9

Please sign in to comment.