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;
}
Aggregations