1
|
package eu.dnetlib.openaire.exporter.aop;
|
2
|
|
3
|
import io.prometheus.client.Gauge;
|
4
|
import org.aspectj.lang.ProceedingJoinPoint;
|
5
|
import org.aspectj.lang.annotation.Around;
|
6
|
import org.aspectj.lang.annotation.Aspect;
|
7
|
import org.springframework.stereotype.Component;
|
8
|
|
9
|
/**
|
10
|
* Created by claudio on 25/07/2017.
|
11
|
*/
|
12
|
@Aspect
|
13
|
@Component
|
14
|
public class DatasourceApiProfiler extends AbstractApiProfiler {
|
15
|
|
16
|
private static final Gauge dsCountries = Gauge.build()
|
17
|
.name("DSM_listCountries_requests_latency_seconds")
|
18
|
.help("Request latency in seconds for invocations of the method DatasourcesApiController.listCountries()")
|
19
|
.register();
|
20
|
|
21
|
@Around("execution(* eu.dnetlib.openaire.exporter.datasource.DatasourcesApiController.listCountries(..))")
|
22
|
public Object logTimelistCountries(final ProceedingJoinPoint joinPoint) throws Throwable {
|
23
|
return _measure(joinPoint, dsCountries.startTimer());
|
24
|
}
|
25
|
|
26
|
private static final Gauge dsSearch = Gauge.build()
|
27
|
.name("DSM_search_requests_latency_seconds")
|
28
|
.help("Request latency in seconds for invocations of the method DatasourcesApiController.search()")
|
29
|
.register();
|
30
|
|
31
|
@Around("execution(* eu.dnetlib.openaire.exporter.datasource.DatasourcesApiController.search(..))")
|
32
|
public Object logTimeDsSearch(final ProceedingJoinPoint joinPoint) throws Throwable {
|
33
|
return _measure(joinPoint, dsSearch.startTimer());
|
34
|
}
|
35
|
|
36
|
private static final Gauge dsSearchBaseUrls = Gauge.build()
|
37
|
.name("DSM_searchBaseUrls_requests_latency_seconds")
|
38
|
.help("Request latency in seconds for invocations of the method DatasourcesApiController.searchBaseUrls()")
|
39
|
.register();
|
40
|
|
41
|
@Around("execution(* eu.dnetlib.openaire.exporter.datasource.DatasourcesApiController.searchBaseUrls(..))")
|
42
|
public Object logTimeDsSearchBaseUrl(final ProceedingJoinPoint joinPoint) throws Throwable {
|
43
|
return _measure(joinPoint, dsSearchBaseUrls.startTimer());
|
44
|
}
|
45
|
|
46
|
private static final Gauge apiGetById = Gauge.build()
|
47
|
.name("DSM_getApi_requests_latency_seconds")
|
48
|
.help("Request latency in seconds for invocations of the method DatasourcesApiController.getApis()")
|
49
|
.register();
|
50
|
|
51
|
@Around("execution(* eu.dnetlib.openaire.exporter.datasource.DatasourcesApiController.getApi(..))")
|
52
|
public Object logTimeApiGetById(final ProceedingJoinPoint joinPoint) throws Throwable {
|
53
|
return _measure(joinPoint, apiGetById.startTimer());
|
54
|
}
|
55
|
|
56
|
}
|