Search in sources :

Example 1 with OpenMetricsExporter

use of fish.payara.microprofile.metrics.writer.OpenMetricsExporter in project Payara by payara.

the class MetricsResource method getOutputWriter.

@SuppressWarnings("resource")
private static MetricsWriter getOutputWriter(HttpServletRequest request, HttpServletResponse response, MetricsService service, String contentType) throws IOException {
    Writer writer = response.getWriter();
    String method = request.getMethod();
    if (GET.equalsIgnoreCase(method)) {
        if (APPLICATION_JSON.equals(contentType)) {
            return new MetricsWriterImpl(new JsonExporter(writer, Mode.GET, true), service.getContextNames(), service::getContext, getGlobalTags());
        }
        if (TEXT_PLAIN.equals(contentType)) {
            return new MetricsWriterImpl(new OpenMetricsExporter(writer), service.getContextNames(), service::getContext, getGlobalTags());
        }
    }
    if (OPTIONS.equalsIgnoreCase(method)) {
        if (APPLICATION_JSON.equals(contentType)) {
            return new MetricsWriterImpl(new JsonExporter(writer, Mode.OPTIONS, true), service.getContextNames(), service::getContext, getGlobalTags());
        }
    }
    return null;
}
Also used : MetricsWriterImpl(fish.payara.microprofile.metrics.writer.MetricsWriterImpl) OpenMetricsExporter(fish.payara.microprofile.metrics.writer.OpenMetricsExporter) JsonExporter(fish.payara.microprofile.metrics.writer.JsonExporter) MetricsWriter(fish.payara.microprofile.metrics.writer.MetricsWriter) Writer(java.io.Writer)

Aggregations

JsonExporter (fish.payara.microprofile.metrics.writer.JsonExporter)1 MetricsWriter (fish.payara.microprofile.metrics.writer.MetricsWriter)1 MetricsWriterImpl (fish.payara.microprofile.metrics.writer.MetricsWriterImpl)1 OpenMetricsExporter (fish.payara.microprofile.metrics.writer.OpenMetricsExporter)1 Writer (java.io.Writer)1