Skip to content

Commit

Permalink
PP-11548: Update prometheus initialisation
Browse files Browse the repository at this point in the history
  • Loading branch information
jfharden committed Sep 19, 2023
1 parent 88596d4 commit d4faf1e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
6 changes: 5 additions & 1 deletion build-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ set -e
cd "$(dirname "$0")"

mvn -DskipITs clean verify
docker build -t govukpay/adminusers:local .
if [ "$(uname -m)" == "arm64" ]; then
docker build -t governmentdigitalservice/pay-adminusers:local -f m1/arm64.Dockerfile .
else
docker build -t governmentdigitalservice/pay-adminusers:local .
fi
10 changes: 2 additions & 8 deletions src/main/java/uk/gov/pay/adminusers/app/AdminUsersApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import uk.gov.pay.adminusers.resources.UserResource;
import uk.gov.service.payments.commons.utils.healthchecks.DatabaseHealthCheck;
import uk.gov.service.payments.commons.utils.metrics.DatabaseMetricsService;
import uk.gov.service.payments.commons.utils.prometheus.PrometheusDefaultLabelSampleBuilder;
import uk.gov.service.payments.logging.GovUkPayDropwizardRequestJsonLogLayoutFactory;
import uk.gov.service.payments.logging.LoggingFilter;
import uk.gov.service.payments.logging.LogstashConsoleAppenderFactory;
Expand Down Expand Up @@ -121,13 +120,8 @@ private void initialiseMetrics(AdminUsersConfig configuration, Environment envir
.build()
.scheduleAtFixedRate(metricsService::updateMetricData, 0, METRICS_COLLECTION_PERIOD_SECONDS / 2, TimeUnit.SECONDS);

configuration.getEcsContainerMetadataUriV4().ifPresent(uri -> initialisePrometheusMetrics(environment, uri));
}

private void initialisePrometheusMetrics(Environment environment, URI ecsContainerMetadataUri) {
logger.info("Initialising prometheus metrics.");
CollectorRegistry collectorRegistry = new CollectorRegistry();
collectorRegistry.register(new DropwizardExports(environment.metrics(), new PrometheusDefaultLabelSampleBuilder(ecsContainerMetadataUri)));
CollectorRegistry collectorRegistry = CollectorRegistry.defaultRegistry;
collectorRegistry.register(new DropwizardExports(environment.metrics()));
environment.admin().addServlet("prometheusMetrics", new MetricsServlet(collectorRegistry)).addMapping("/metrics");
}

Expand Down

0 comments on commit d4faf1e

Please sign in to comment.