use of fish.payara.microprofile.metrics.writer.MetricsWriterImpl in project Payara by payara.
the class MicroProfileMetricsCheck method constructOptions.
@Override
public synchronized HealthCheckMicroProfileMetricstExecutionOptions constructOptions(MicroProfileMetricsChecker checker) {
Set<String> metricNames = new HashSet<>();
for (MonitoredMetric metric : checker.getMonitoredMetrics()) {
metricNames.add(metric.getMetricName());
}
this.buffer = new StringWriterProxy();
this.writer = new MetricsWriterImpl(new FilteredMetricsExporter(buffer, metricNames), metricsService.getContextNames(), metricsService::getContext);
return new HealthCheckMicroProfileMetricstExecutionOptions(Boolean.valueOf(checker.getEnabled()), Long.parseLong(checker.getTime()), asTimeUnit(checker.getUnit()), Boolean.valueOf(checker.getAddToMicroProfileHealth()), checker.getMonitoredMetrics());
}
use of fish.payara.microprofile.metrics.writer.MetricsWriterImpl 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