34 lines
1.2 KiB
Java
34 lines
1.2 KiB
Java
package eu.dnetlib.organizations.controller;
|
|
|
|
import static org.springframework.http.HttpHeaders.CONTENT_TYPE;
|
|
|
|
import java.util.Set;
|
|
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.web.bind.annotation.RequestHeader;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
import eu.dnetlib.common.metrics.MetricUtils;
|
|
import io.prometheus.client.exporter.common.TextFormat;
|
|
|
|
@Controller
|
|
public class KpiMetricsController {
|
|
|
|
@ResponseBody
|
|
@RequestMapping(value = "/kpis", method = RequestMethod.GET, produces = "*/*")
|
|
public ResponseEntity<String> kpiMetrics(
|
|
@RequestParam(value = "name[]", required = false, defaultValue = "") final Set<String> name,
|
|
@RequestHeader(value = "Accept", required = false, defaultValue = "") final String accept) {
|
|
|
|
final String contentType = TextFormat.chooseContentType(accept);
|
|
final String result = MetricUtils.output(name, contentType);
|
|
return ResponseEntity.ok()
|
|
.header(CONTENT_TYPE, contentType)
|
|
.body(result);
|
|
}
|
|
}
|