1
|
package eu.dnetlib.data.search.web.api;
|
2
|
|
3
|
import io.micrometer.prometheus.PrometheusMeterRegistry;
|
4
|
import org.springframework.beans.factory.annotation.Autowired;
|
5
|
import org.springframework.context.annotation.ComponentScan;
|
6
|
import org.springframework.http.MediaType;
|
7
|
import org.springframework.stereotype.Component;
|
8
|
import org.springframework.stereotype.Controller;
|
9
|
import org.springframework.web.bind.annotation.RequestMapping;
|
10
|
import org.springframework.web.bind.annotation.RequestMethod;
|
11
|
import org.springframework.web.bind.annotation.ResponseBody;
|
12
|
|
13
|
import javax.servlet.http.HttpServletRequest;
|
14
|
import javax.servlet.http.HttpServletResponse;
|
15
|
|
16
|
@Controller
|
17
|
@ComponentScan
|
18
|
@Component
|
19
|
public class MicrometerPublisher {
|
20
|
|
21
|
@Autowired
|
22
|
PrometheusMeterRegistry registry;
|
23
|
|
24
|
@RequestMapping(method = RequestMethod.GET, value = "/metrics", produces = {MediaType.TEXT_PLAIN_VALUE})
|
25
|
@ResponseBody
|
26
|
public String getMetrics(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
27
|
return registry.scrape();
|
28
|
}
|
29
|
}
|