diff --git a/CHANGELOG.md b/CHANGELOG.md index 31ce6703f..58e15b987 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,119 @@ +## [1.27.8](https://github.com/gravitee-io/gravitee-node/compare/1.27.7...1.27.8) (2023-04-27) + + +### Bug Fixes + +* add 'With' methods to HttpServerConfiguration ([1051060](https://github.com/gravitee-io/gravitee-node/commit/1051060a81435c7b67c69ee972e5447b6386d716)) +* add 'With' methods to HttpServerConfiguration ([a0bb68f](https://github.com/gravitee-io/gravitee-node/commit/a0bb68f5b2a57bbef1709292c583c18602ce6ce7)) +* **api:** load the right property source for /configuration ([f9580e2](https://github.com/gravitee-io/gravitee-node/commit/f9580e26395fc4b92d72b81d7eb5c6f10e3fc784)) +* **api:** load the right property source for /configuration ([563b0f8](https://github.com/gravitee-io/gravitee-node/commit/563b0f8f62f278a52f9a355c9b7dd90b1e290465)) +* **api:** send head before writing response for /monitor ([08d02ea](https://github.com/gravitee-io/gravitee-node/commit/08d02ead134ee9a318ccbd58d8465d40378dbf76)) +* **api:** send head before writing response for /monitor ([3700dd0](https://github.com/gravitee-io/gravitee-node/commit/3700dd0cf91db2b9b182e3e940831cf22dc61bca)) +* avoid spring loading issue with vertx and k8s client ([fe829f9](https://github.com/gravitee-io/gravitee-node/commit/fe829f9fcf9b80f2525925316553aa1db54737b7)) +* bump kubernetes client ([137eaf0](https://github.com/gravitee-io/gravitee-node/commit/137eaf0e48c306882cb37438a16968ece6684b24)) +* **prometheus:** Stream scraping output instead of using a single String instance ([6e4271b](https://github.com/gravitee-io/gravitee-node/commit/6e4271bf66faa109bd21b078629fc1f7ed895f51)) + +## [1.25.6](https://github.com/gravitee-io/gravitee-node/compare/1.25.5...1.25.6) (2023-04-27) + + +### Bug Fixes + +* add 'With' methods to HttpServerConfiguration ([a0bb68f](https://github.com/gravitee-io/gravitee-node/commit/a0bb68f5b2a57bbef1709292c583c18602ce6ce7)) +* **api:** load the right property source for /configuration ([563b0f8](https://github.com/gravitee-io/gravitee-node/commit/563b0f8f62f278a52f9a355c9b7dd90b1e290465)) +* **api:** send head before writing response for /monitor ([3700dd0](https://github.com/gravitee-io/gravitee-node/commit/3700dd0cf91db2b9b182e3e940831cf22dc61bca)) +* **prometheus:** Stream scraping output instead of using a single String instance ([6e4271b](https://github.com/gravitee-io/gravitee-node/commit/6e4271bf66faa109bd21b078629fc1f7ed895f51)) + +## [1.24.7](https://github.com/gravitee-io/gravitee-node/compare/1.24.6...1.24.7) (2023-04-24) + + +### Bug Fixes + +* **prometheus:** Stream scraping output instead of using a single String instance ([6e4271b](https://github.com/gravitee-io/gravitee-node/commit/6e4271bf66faa109bd21b078629fc1f7ed895f51)) + +## [1.24.6](https://github.com/gravitee-io/gravitee-node/compare/1.24.5...1.24.6) (2023-03-31) + + +### Bug Fixes + +* add 'With' methods to HttpServerConfiguration ([a0bb68f](https://github.com/gravitee-io/gravitee-node/commit/a0bb68f5b2a57bbef1709292c583c18602ce6ce7)) + +## [1.24.5](https://github.com/gravitee-io/gravitee-node/compare/1.24.4...1.24.5) (2023-02-16) + + +### Bug Fixes + +* **api:** load the right property source for /configuration ([563b0f8](https://github.com/gravitee-io/gravitee-node/commit/563b0f8f62f278a52f9a355c9b7dd90b1e290465)) + +## [1.24.4](https://github.com/gravitee-io/gravitee-node/compare/1.24.3...1.24.4) (2023-02-10) + + +### Bug Fixes + +* **api:** send head before writing response for /monitor ([3700dd0](https://github.com/gravitee-io/gravitee-node/commit/3700dd0cf91db2b9b182e3e940831cf22dc61bca)) + +## [1.25.5](https://github.com/gravitee-io/gravitee-node/compare/1.25.4...1.25.5) (2023-04-06) + + +### Bug Fixes + +* bump kubernetes client ([137eaf0](https://github.com/gravitee-io/gravitee-node/commit/137eaf0e48c306882cb37438a16968ece6684b24)) + +## [1.25.4](https://github.com/gravitee-io/gravitee-node/compare/1.25.3...1.25.4) (2023-03-31) + + +### Bug Fixes + +* add 'With' methods to HttpServerConfiguration ([1051060](https://github.com/gravitee-io/gravitee-node/commit/1051060a81435c7b67c69ee972e5447b6386d716)) + +## [1.25.3](https://github.com/gravitee-io/gravitee-node/compare/1.25.2...1.25.3) (2023-03-07) + + +### Bug Fixes + +* avoid spring loading issue with vertx and k8s client ([fe829f9](https://github.com/gravitee-io/gravitee-node/commit/fe829f9fcf9b80f2525925316553aa1db54737b7)) + +## [1.25.2](https://github.com/gravitee-io/gravitee-node/compare/1.25.1...1.25.2) (2023-02-16) + + +### Bug Fixes + +* **api:** load the right property source for /configuration ([f9580e2](https://github.com/gravitee-io/gravitee-node/commit/f9580e26395fc4b92d72b81d7eb5c6f10e3fc784)) + +## [1.25.1](https://github.com/gravitee-io/gravitee-node/compare/1.25.0...1.25.1) (2023-02-10) + + +### Bug Fixes + +* **api:** send head before writing response for /monitor ([08d02ea](https://github.com/gravitee-io/gravitee-node/commit/08d02ead134ee9a318ccbd58d8465d40378dbf76)) + +## [1.27.7](https://github.com/gravitee-io/gravitee-node/compare/1.27.6...1.27.7) (2023-03-13) + + +### Bug Fixes + +* avoid spring loading issue with vertx and k8s client ([ccbb643](https://github.com/gravitee-io/gravitee-node/commit/ccbb643f846aac4ea3e3647448bb1113cf44d6ce)) + +## [1.27.6](https://github.com/gravitee-io/gravitee-node/compare/1.27.5...1.27.6) (2023-03-09) + + +### Bug Fixes + +* remove enforced INFO level for license ([0515ec5](https://github.com/gravitee-io/gravitee-node/commit/0515ec5a8acbe660cc3e9fa042edf21b535b0568)) + +## [1.27.5](https://github.com/gravitee-io/gravitee-node/compare/1.27.4...1.27.5) (2023-02-16) + + +### Bug Fixes + +* **api:** load the right property source for /configuration ([935a394](https://github.com/gravitee-io/gravitee-node/commit/935a39473f78e4a0ab90b8a360694730bd4f31bf)) + +## [1.27.4](https://github.com/gravitee-io/gravitee-node/compare/1.27.3...1.27.4) (2023-02-10) + + +### Bug Fixes + +* **api:** send head before writing response for /monitor ([66abc90](https://github.com/gravitee-io/gravitee-node/commit/66abc903384881e8bedd4b1f4b6141ba061d9c7d)) + ## [2.0.6](https://github.com/gravitee-io/gravitee-node/compare/2.0.5...2.0.6) (2023-03-31) diff --git a/gravitee-node-license/pom.xml b/gravitee-node-license/pom.xml index 0382685c2..cc6054cd6 100644 --- a/gravitee-node-license/pom.xml +++ b/gravitee-node-license/pom.xml @@ -58,14 +58,6 @@ org.slf4j slf4j-api - - ch.qos.logback - logback-classic - - - ch.qos.logback - logback-core - diff --git a/gravitee-node-license/src/main/java/io/gravitee/node/license/LicenseService.java b/gravitee-node-license/src/main/java/io/gravitee/node/license/LicenseService.java index f9fd51566..075edcdd3 100644 --- a/gravitee-node-license/src/main/java/io/gravitee/node/license/LicenseService.java +++ b/gravitee-node-license/src/main/java/io/gravitee/node/license/LicenseService.java @@ -15,7 +15,6 @@ */ package io.gravitee.node.license; -import ch.qos.logback.classic.Level; import io.gravitee.common.service.AbstractService; import io.gravitee.node.api.Node; import io.gravitee.node.license.license3j.License3JLicense; @@ -119,9 +118,6 @@ public io.gravitee.node.api.license.License getLicense() { protected void doStart() throws Exception { super.doStart(); - // Ensure log level for license module to INFO - ((ch.qos.logback.classic.Logger) logger).setLevel(Level.INFO); - this.loadLicense(); this.startLicenseChecker(); this.startLicenseWatcher(); diff --git a/gravitee-node-management/src/main/java/io/gravitee/node/management/http/metrics/prometheus/PrometheusEndpoint.java b/gravitee-node-management/src/main/java/io/gravitee/node/management/http/metrics/prometheus/PrometheusEndpoint.java index 3f3d30f60..2609c9f5b 100644 --- a/gravitee-node-management/src/main/java/io/gravitee/node/management/http/metrics/prometheus/PrometheusEndpoint.java +++ b/gravitee-node-management/src/main/java/io/gravitee/node/management/http/metrics/prometheus/PrometheusEndpoint.java @@ -15,11 +15,20 @@ */ package io.gravitee.node.management.http.metrics.prometheus; +import static io.prometheus.client.exporter.common.TextFormat.*; +import static io.vertx.core.http.HttpHeaders.*; + import io.gravitee.common.http.HttpMethod; import io.gravitee.node.management.http.endpoint.ManagementEndpoint; import io.micrometer.prometheus.PrometheusMeterRegistry; +import io.vertx.core.buffer.Buffer; +import io.vertx.core.http.HttpServerResponse; import io.vertx.ext.web.RoutingContext; import io.vertx.micrometer.backends.BackendRegistries; +import java.io.IOException; +import java.io.Writer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author David BRASSELY (david.brassely at graviteesource.com) @@ -27,6 +36,8 @@ */ public class PrometheusEndpoint implements ManagementEndpoint { + private static final Logger LOGGER = LoggerFactory.getLogger(PrometheusEndpoint.class); + @Override public HttpMethod method() { return HttpMethod.GET; @@ -39,7 +50,72 @@ public String path() { @Override public void handle(RoutingContext routingContext) { - String response = ((PrometheusMeterRegistry) BackendRegistries.getDefaultNow()).scrape(); - routingContext.response().end(response); + PrometheusMeterRegistry registry = (PrometheusMeterRegistry) BackendRegistries.getDefaultNow(); + HttpServerResponse response = routingContext.response(); + + response.putHeader(CONTENT_TYPE, CONTENT_TYPE_004); + response.setChunked(true); + + try (BufferWriter writer = new BufferWriter(response)) { + registry.scrape(writer); + } catch (IOException ioe) { + LOGGER.error("Unexpected error while scraping the Prometheus endpoint", ioe); + response.close(); + } + } + + private static class BufferWriter extends Writer { + + private final HttpServerResponse response; + + private BufferWriter(HttpServerResponse response) { + this.response = response; + } + + @Override + public void write(char[] cbuf, int off, int len) throws IOException { + push(Buffer.buffer(charArrayToByteArray(cbuf))); + } + + @Override + public void write(int c) throws IOException { + push(Buffer.buffer(1).appendByte((byte) (c & 0xFF))); + } + + @Override + public void write(char[] cbuf) throws IOException { + push(Buffer.buffer(new String(cbuf))); + } + + @Override + public void write(String str) throws IOException { + push(Buffer.buffer(str)); + } + + @Override + public void write(String str, int off, int len) throws IOException { + push(Buffer.buffer(str)); + } + + private void push(Buffer buffer) { + response.write(buffer); + } + + @Override + public void flush() {} + + @Override + public void close() throws IOException { + response.end(); + } + } + + private static byte[] charArrayToByteArray(char[] charBuf) { + if (charBuf == null) return null; + int iLen = charBuf.length; + byte[] buf = new byte[iLen]; + for (int p = 0; p < iLen; p++) buf[p] = (byte) (charBuf[p]); + + return buf; } }