use of org.wildfly.swarm.microprofile.metrics.runtime.exporters.JsonMetadataExporter in project wildfly-swarm by wildfly-swarm.
the class MetricsHttpHandler method obtainExporter.
/**
* Determine which exporter we want.
* @param exchange The http exchange coming in
* @return An exporter instance or null in case no matching exporter existed.
*/
private Exporter obtainExporter(HttpServerExchange exchange) {
HeaderValues acceptHeaders = exchange.getRequestHeaders().get(Headers.ACCEPT);
Exporter exporter;
String method = exchange.getRequestMethod().toString();
if (acceptHeaders == null) {
if (method.equals("GET")) {
exporter = new PrometheusExporter();
} else {
return null;
}
} else {
// Header can look like "application/json, text/plain, */*"
if (acceptHeaders.getFirst() != null && acceptHeaders.getFirst().startsWith("application/json")) {
if (method.equals("GET")) {
exporter = new JsonExporter();
} else if (method.equals("OPTIONS")) {
exporter = new JsonMetadataExporter();
} else {
return null;
}
} else {
// This is the fallback, but only for GET, as Prometheus does not support OPTIONS
if (method.equals("GET")) {
exporter = new PrometheusExporter();
} else {
return null;
}
}
}
return exporter;
}
Aggregations