summaryrefslogtreecommitdiffstats
path: root/controller-server/src
diff options
context:
space:
mode:
authorJon Marius Venstad <jvenstad@yahoo-inc.com>2019-01-11 11:58:11 +0100
committerJon Marius Venstad <jvenstad@yahoo-inc.com>2019-01-11 11:58:11 +0100
commit92c66f996f93ed66c8f82114b910585902f29e37 (patch)
tree835ab7c12a578ca0a1b8e7f33368719f9cd61c62 /controller-server/src
parent0dec7e17ef43134b0342df0f8699ac4d6d78a383 (diff)
Emit metric with build age in seconds for all apps with prod deployments
Diffstat (limited to 'controller-server/src')
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporter.java10
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/ApplicationPackageBuilder.java7
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporterTest.java14
3 files changed, 31 insertions, 0 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporter.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporter.java
index 305241a7d0e..2ae38fabb94 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporter.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporter.java
@@ -11,6 +11,7 @@ import com.yahoo.vespa.hosted.controller.api.integration.chef.AttributeMapping;
import com.yahoo.vespa.hosted.controller.api.integration.chef.Chef;
import com.yahoo.vespa.hosted.controller.api.integration.chef.rest.PartialNode;
import com.yahoo.vespa.hosted.controller.api.integration.chef.rest.PartialNodeResult;
+import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType;
import com.yahoo.vespa.hosted.controller.application.ApplicationList;
import com.yahoo.vespa.hosted.controller.application.JobList;
import com.yahoo.vespa.hosted.controller.application.JobStatus;
@@ -37,6 +38,7 @@ public class MetricsReporter extends Maintainer {
public static final String deploymentFailMetric = "deployment.failurePercentage";
public static final String deploymentAverageDuration = "deployment.averageDuration";
public static final String deploymentFailingUpgrades = "deployment.failingUpgrades";
+ public static final String deploymentBuildAgeSeconds = "deployment.buildAgeSeconds";
public static final String remainingRotations = "remaining_rotations";
private final Metric metric;
@@ -128,6 +130,14 @@ public class MetricsReporter extends Maintainer {
deploymentsFailingUpgrade(applications).forEach((application, failingJobs) -> {
metric.set(deploymentFailingUpgrades, failingJobs, metric.createContext(dimensions(application)));
});
+
+ for (Application application : applications.asList())
+ application.deploymentJobs().statusOf(JobType.component)
+ .flatMap(JobStatus::lastSuccess)
+ .flatMap(run -> run.application().buildTime())
+ .ifPresent(buildTime -> metric.set(deploymentBuildAgeSeconds,
+ controller().clock().instant().getEpochSecond() - buildTime.getEpochSecond(),
+ metric.createContext(dimensions(application.id()))));
}
private static double deploymentFailRatio(ApplicationList applicationList) {
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/ApplicationPackageBuilder.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/ApplicationPackageBuilder.java
index 0499a92d05f..44a797687d4 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/ApplicationPackageBuilder.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/ApplicationPackageBuilder.java
@@ -170,6 +170,10 @@ public class ApplicationPackageBuilder {
return searchDefinition.getBytes(StandardCharsets.UTF_8);
}
+ private byte[] buildMeta() {
+ return "{\"compileVersion\":\"6.1\",\"buildTime\":1000}".getBytes(StandardCharsets.UTF_8);
+ }
+
public ApplicationPackage build() {
ByteArrayOutputStream zip = new ByteArrayOutputStream();
try (ZipOutputStream out = new ZipOutputStream(zip)) {
@@ -182,6 +186,9 @@ public class ApplicationPackageBuilder {
out.putNextEntry(new ZipEntry("search-definitions/test.sd"));
out.write(searchDefinition());
out.closeEntry();
+ out.putNextEntry(new ZipEntry("build-meta.json"));
+ out.write(buildMeta());
+ out.closeEntry();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporterTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporterTest.java
index 7ab858f3081..9c01e526a50 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporterTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporterTest.java
@@ -11,9 +11,11 @@ import com.yahoo.vespa.hosted.controller.Controller;
import com.yahoo.vespa.hosted.controller.ControllerTester;
import com.yahoo.vespa.hosted.controller.api.integration.chef.ChefMock;
import com.yahoo.vespa.hosted.controller.api.integration.chef.rest.PartialNodeResult;
+import com.yahoo.vespa.hosted.controller.api.integration.deployment.ApplicationVersion;
import com.yahoo.vespa.hosted.controller.application.ApplicationPackage;
import com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder;
import com.yahoo.vespa.hosted.controller.deployment.DeploymentTester;
+import com.yahoo.vespa.hosted.controller.deployment.InternalDeploymentTester;
import com.yahoo.vespa.hosted.controller.integration.MetricsMock;
import com.yahoo.vespa.hosted.controller.integration.MetricsMock.MapContext;
import com.yahoo.vespa.hosted.controller.persistence.MockCuratorDb;
@@ -204,6 +206,18 @@ public class MetricsReporterTest {
assertEquals(0, getDeploymentsFailingUpgrade(app));
}
+ @Test
+ public void testBuildTimeReporting() {
+ InternalDeploymentTester tester = new InternalDeploymentTester();
+ ApplicationVersion version = tester.deployNewSubmission();
+ assertEquals(1000, version.buildTime().get().toEpochMilli());
+
+ MetricsReporter reporter = createReporter(tester.tester().controller(), metrics, SystemName.main);
+ reporter.maintain();
+ assertEquals(tester.clock().instant().getEpochSecond() - 1,
+ getMetric(MetricsReporter.deploymentBuildAgeSeconds, tester.app()));
+ }
+
private Duration getAverageDeploymentDuration(Application application) {
return Duration.ofSeconds(getMetric(MetricsReporter.deploymentAverageDuration, application).longValue());
}