From afa5e12da8224630b206fe9c9d486f5ef99e60a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Thu, 12 May 2022 16:36:50 +0200 Subject: [PATCH] Breaking - Remove the statsd metrics, dependency no more available --- Makefile | 1 + build.gradle | 7 +- core/build.gradle | 2 - .../print/metrics/StatsDReporterInit.java | 91 ------------------- .../mapfish-spring-application-context.xml | 1 - docs/build.gradle | 1 - examples/build.gradle | 1 - 7 files changed, 3 insertions(+), 101 deletions(-) delete mode 100644 core/src/main/java/org/mapfish/print/metrics/StatsDReporterInit.java diff --git a/Makefile b/Makefile index 83e10b76eb..a8ae3612d3 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ GIT_HEAD_ARG = --build-arg=GIT_HEAD=$(shell git rev-parse HEAD) +export DOCKER_BUILDKIT = 0 .PHONY: build build: diff --git a/build.gradle b/build.gradle index 5e32b041d5..014a6536dc 100644 --- a/build.gradle +++ b/build.gradle @@ -1,10 +1,7 @@ buildscript { repositories { - mavenLocal() - jcenter() - maven { - url "https://plugins.gradle.org/m2/" - } + mavenCentral() + maven { url "https://plugins.gradle.org/m2/" } } dependencies { diff --git a/core/build.gradle b/core/build.gradle index b5bfa7eef9..27a7ec9d88 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -8,7 +8,6 @@ defaultTasks 'build' repositories { mavenCentral() - jcenter() maven { url "https://jaspersoft.jfrog.io/jaspersoft/third-party-ce-artifacts" } maven { url "https://repo.osgeo.org/repository/release/" } } @@ -141,7 +140,6 @@ dependencies { "io.dropwizard.metrics:metrics-jvm:4.2.13", "io.dropwizard.metrics:metrics-jmx:4.2.13", "io.dropwizard.metrics:metrics-logback:4.2.13", - 'com.readytalk:metrics3-statsd:4.2.0' ) geotools( "org.geotools:gt-epsg-hsql:28.0", diff --git a/core/src/main/java/org/mapfish/print/metrics/StatsDReporterInit.java b/core/src/main/java/org/mapfish/print/metrics/StatsDReporterInit.java deleted file mode 100644 index 5d03d69c86..0000000000 --- a/core/src/main/java/org/mapfish/print/metrics/StatsDReporterInit.java +++ /dev/null @@ -1,91 +0,0 @@ -package org.mapfish.print.metrics; - -import com.codahale.metrics.MetricRegistry; -import com.readytalk.metrics.StatsDReporter; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; - -import java.net.InetAddress; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.UnknownHostException; -import java.util.concurrent.TimeUnit; - -import javax.annotation.PostConstruct; -import javax.annotation.PreDestroy; - -/** - * Will start a StatsD reporter if configured. Using those environment variables or Java system properties: - - * STATSD_ADDRESS: the address:port of the statsd daemon (if not set, the feature is disabled) - - * STATSD_PREFIX: the prefix to set (defaults to mapfish-print). Can use %h to insert the hostname. - - * STATSD_PERIOD: the reporting period in seconds (defaults to 10) - */ -public class StatsDReporterInit { - private static final String ADDRESS = "STATSD_ADDRESS"; - private static final String PREFIX = "STATSD_PREFIX"; - private static final String PERIOD = "STATSD_PERIOD"; - private static final Logger LOGGER = LoggerFactory.getLogger(StatsDReporterInit.class); - - @Autowired - private MetricRegistry metricRegistry; - - private StatsDReporter reporter = null; - - private static String getHostname() { - String hostname = System.getenv("HOSTNAME"); // should work on Unix - if (hostname == null) { - hostname = System.getenv("COMPUTERNAME"); // should work on Windows - } - if (hostname == null) { - try { - // last resort - hostname = InetAddress.getLocalHost().getHostName(); - } catch (UnknownHostException e) { - hostname = "unknown"; // fallback - } - } - return hostname.toLowerCase(); - } - - private String getConfig(final String name, final String def) { - final String result = System.getenv(name); - if (result == null) { - return System.getProperty(name, def); - } - return result; - } - - /** - * Start the StatsD reporter, if configured. - * - * @throws URISyntaxException - */ - @PostConstruct - public final void init() throws URISyntaxException { - final String address = getConfig(ADDRESS, null); - if (address != null) { - final URI uri = new URI("udp://" + address); - final String prefix = getConfig(PREFIX, "mapfish-print").replace("%h", getHostname()); - final int period = Integer.parseInt(getConfig(PERIOD, "10")); - LOGGER.info("Starting a StatsD reporter targeting {} with prefix {} and period {}s", - uri, prefix, period); - this.reporter = StatsDReporter.forRegistry(this.metricRegistry) - .prefixedWith(prefix) - .build(uri.getHost(), uri.getPort()); - this.reporter.start(period, TimeUnit.SECONDS); - } - } - - /** - * Stop the StatsD reporter, if configured. - */ - @PreDestroy - public final void shutdown() { - if (this.reporter != null) { - LOGGER.info("Stopping the StatsD reporter"); - this.reporter.stop(); - } - } -} diff --git a/core/src/main/resources/mapfish-spring-application-context.xml b/core/src/main/resources/mapfish-spring-application-context.xml index ba63f64e54..7b69183cb7 100644 --- a/core/src/main/resources/mapfish-spring-application-context.xml +++ b/core/src/main/resources/mapfish-spring-application-context.xml @@ -66,7 +66,6 @@ - diff --git a/docs/build.gradle b/docs/build.gradle index 2a8ae53f6e..32c7981faa 100644 --- a/docs/build.gradle +++ b/docs/build.gradle @@ -6,7 +6,6 @@ defaultTasks 'build' repositories { mavenCentral() - jcenter() maven { url "https://jaspersoft.jfrog.io/jaspersoft/third-party-ce-artifacts" } maven { url "https://repo.osgeo.org/repository/release/" } } diff --git a/examples/build.gradle b/examples/build.gradle index 1fe97fea8e..185ca736da 100644 --- a/examples/build.gradle +++ b/examples/build.gradle @@ -2,7 +2,6 @@ import org.gradle.api.tasks.testing.logging.TestLogEvent repositories { mavenCentral() - jcenter() maven { url 'https://maven.restlet.org' } maven { url "https://jaspersoft.jfrog.io/jaspersoft/third-party-ce-artifacts" } maven { url "https://repo.osgeo.org/repository/release/" }