Skip to content

Commit

Permalink
remove prometheus-include-last-value javamelody parameter and replace…
Browse files Browse the repository at this point in the history
… with includeLastValue http parameter
  • Loading branch information
evernat committed Jun 11, 2018
1 parent 33fe61d commit 08aacb2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
Expand Up @@ -377,12 +377,7 @@ public enum Parameter {
* API key of the <a href='https://www.datadoghq.com/'>Datadog</a> to send metrics,
* for example: 9775a026f1ca7d1c6c5af9d94d9595a4 (null by default).
*/
DATADOG_API_KEY("datadog-api-key"),

/**
* Includes last values of graphs when sending metrics to <a href='https://prometheus.io/'>Prometheus</a> (false by default).
*/
PROMETHEUS_INCLUDE_LAST_VALUE("prometheus-include-last-value");
DATADOG_API_KEY("datadog-api-key");

private final String code;

Expand Down
Expand Up @@ -233,9 +233,11 @@ private void doReportCore(HttpServletRequest httpRequest, HttpServletResponse ht
pdfController.doPdf(httpRequest, httpResponse, javaInformationsList);
} else if ("prometheus".equalsIgnoreCase(format)) {
httpResponse.setContentType("text/plain; version=0.0.4;charset=UTF-8");
final boolean includeLastValue = Boolean
.parseBoolean(httpRequest.getParameter("includeLastValue"));
final PrometheusController prometheusController = new PrometheusController(
javaInformationsList, collector, httpResponse.getWriter());
prometheusController.report();
prometheusController.report(includeLastValue);
} else {
doCompressedSerializable(httpRequest, httpResponse, javaInformationsList);
}
Expand Down
Expand Up @@ -28,7 +28,6 @@
import java.util.Map;
import java.util.regex.Pattern;

import net.bull.javamelody.Parameter;
import net.bull.javamelody.internal.common.Parameters;
import net.bull.javamelody.internal.model.CacheInformations;
import net.bull.javamelody.internal.model.Collector;
Expand Down Expand Up @@ -202,9 +201,10 @@ public String getCode() {

/**
* Produce the full report.
* @param includeLastValue boolean
* @throws IOException e
*/
void report() throws IOException {
void report(boolean includeLastValue) throws IOException {
// see https://prometheus.io/docs/instrumenting/exposition_formats/ for text format
// memory
reportOnMemoryInformations(javaInformations.getMemoryInformations());
Expand All @@ -224,7 +224,7 @@ void report() throws IOException {

reportOnCollector();

if (Parameter.PROMETHEUS_INCLUDE_LAST_VALUE.getValueAsBoolean()) {
if (includeLastValue) {
reportOnLastValues();
}
}
Expand Down

0 comments on commit 08aacb2

Please sign in to comment.