diff options
author | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2019-01-11 11:58:11 +0100 |
---|---|---|
committer | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2019-01-11 11:58:11 +0100 |
commit | 92c66f996f93ed66c8f82114b910585902f29e37 (patch) | |
tree | 835ab7c12a578ca0a1b8e7f33368719f9cd61c62 /controller-server | |
parent | 0dec7e17ef43134b0342df0f8699ac4d6d78a383 (diff) |
Emit metric with build age in seconds for all apps with prod deployments
Diffstat (limited to 'controller-server')
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()); } |