Revision 50895
Added by Claudio Atzori about 5 years ago
modules/dnet-openaire-exporter/trunk/src/main/java/eu/dnetlib/openaire/exporter/aop/AbstractApiProfiler.java | ||
---|---|---|
1 |
package eu.dnetlib.openaire.exporter.aop; |
|
2 |
|
|
3 |
import io.prometheus.client.Gauge.Timer; |
|
4 |
import org.aspectj.lang.ProceedingJoinPoint; |
|
5 |
|
|
6 |
public abstract class AbstractApiProfiler { |
|
7 |
|
|
8 |
// HELPER |
|
9 |
|
|
10 |
protected Object _measure(final ProceedingJoinPoint joinPoint, final Timer requestTimer) throws Throwable { |
|
11 |
try { |
|
12 |
return joinPoint.proceed(); |
|
13 |
} finally { |
|
14 |
requestTimer.setDuration(); |
|
15 |
} |
|
16 |
} |
|
17 |
|
|
18 |
} |
modules/dnet-openaire-exporter/trunk/src/main/java/eu/dnetlib/openaire/exporter/aop/CommunityApiProfiler.java | ||
---|---|---|
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 |
@Aspect |
|
10 |
@Component |
|
11 |
public class CommunityApiProfiler extends AbstractApiProfiler { |
|
12 |
|
|
13 |
private static final Gauge listCommunities = Gauge.build() |
|
14 |
.name("DSM_listCommunities_requests_latency_seconds") |
|
15 |
.help("Request latency in seconds for invocations of the method CommunityApiController.listCommunities()") |
|
16 |
.register(); |
|
17 |
|
|
18 |
@Around("execution(* eu.dnetlib.openaire.exporter.community.CommunityApiController.listCommunities(..))") |
|
19 |
public Object logTimelistCommunities(final ProceedingJoinPoint joinPoint) throws Throwable { |
|
20 |
return _measure(joinPoint, listCommunities.startTimer()); |
|
21 |
} |
|
22 |
|
|
23 |
private static final Gauge getCommunity = Gauge.build() |
|
24 |
.name("DSM_getCommunity_requests_latency_seconds") |
|
25 |
.help("Request latency in seconds for invocations of the method CommunityApiController.getCommunity()") |
|
26 |
.register(); |
|
27 |
|
|
28 |
@Around("execution(* eu.dnetlib.openaire.exporter.community.CommunityApiController.getCommunity(..))") |
|
29 |
public Object logTimeGetCommunity(final ProceedingJoinPoint joinPoint) throws Throwable { |
|
30 |
return _measure(joinPoint, getCommunity.startTimer()); |
|
31 |
} |
|
32 |
|
|
33 |
private static final Gauge getCommunityProjects = Gauge.build() |
|
34 |
.name("DSM_getCommunityProjects_requests_latency_seconds") |
|
35 |
.help("Request latency in seconds for invocations of the method CommunityApiController.getCommunityProjects()") |
|
36 |
.register(); |
|
37 |
|
|
38 |
@Around("execution(* eu.dnetlib.openaire.exporter.community.CommunityApiController.getCommunityProjects(..))") |
|
39 |
public Object logTimeGetCommunityProjects(final ProceedingJoinPoint joinPoint) throws Throwable { |
|
40 |
return _measure(joinPoint, getCommunityProjects.startTimer()); |
|
41 |
} |
|
42 |
|
|
43 |
private static final Gauge getCommunityContentproviders = Gauge.build() |
|
44 |
.name("DSM_getCommunityContentproviders_requests_latency_seconds") |
|
45 |
.help("Request latency in seconds for invocations of the method CommunityApiController.getCommunityContentproviders()") |
|
46 |
.register(); |
|
47 |
|
|
48 |
@Around("execution(* eu.dnetlib.openaire.exporter.community.CommunityApiController.getCommunityContentproviders(..))") |
|
49 |
public Object logTimeGetCommunityContentproviders(final ProceedingJoinPoint joinPoint) throws Throwable { |
|
50 |
return _measure(joinPoint, getCommunityContentproviders.startTimer()); |
|
51 |
} |
|
52 |
|
|
53 |
} |
modules/dnet-openaire-exporter/trunk/src/main/java/eu/dnetlib/openaire/exporter/aop/DatasourceApiProfiler.java | ||
---|---|---|
11 | 11 |
*/ |
12 | 12 |
@Aspect |
13 | 13 |
@Component |
14 |
public class DatasourceApiProfiler { |
|
14 |
public class DatasourceApiProfiler extends AbstractApiProfiler {
|
|
15 | 15 |
|
16 |
private static final Gauge datasourceByIdGauge = Gauge.build()
|
|
17 |
.name("DSM_getDsById_requests_latency_seconds")
|
|
18 |
.help("Request latency in seconds for invocations of the method eu.dnetlib.openaire.exporter.datasource.DatasourcesApiController.getDs()")
|
|
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 | 19 |
.register(); |
20 | 20 |
|
21 |
@Around("execution(* eu.dnetlib.openaire.exporter.datasource.DatasourcesApiController.getDs(..))") |
|
22 |
public Object logTimeGetDsById(final ProceedingJoinPoint joinPoint) throws Throwable { |
|
23 |
final Gauge.Timer requestTimer = datasourceByIdGauge.startTimer(); |
|
24 |
try { |
|
25 |
return joinPoint.proceed(); |
|
26 |
} finally { |
|
27 |
requestTimer.setDuration(); |
|
28 |
} |
|
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()); |
|
29 | 24 |
} |
30 | 25 |
|
31 |
private static final Gauge datasourceByName = Gauge.build()
|
|
32 |
.name("DSM_searchDsByName_requests_latency_seconds")
|
|
33 |
.help("Request latency in seconds for invocations of the method eu.dnetlib.openaire.exporter.datasource.DatasourcesApiController.searchByName()")
|
|
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()")
|
|
34 | 29 |
.register(); |
35 | 30 |
|
36 |
@Around("execution(* eu.dnetlib.openaire.exporter.datasource.DatasourcesApiController.searchByName(..))") |
|
37 |
public Object logTimeSearchDsByName(final ProceedingJoinPoint joinPoint) throws Throwable { |
|
38 |
final Gauge.Timer requestTimer = datasourceByName.startTimer(); |
|
39 |
try { |
|
40 |
return joinPoint.proceed(); |
|
41 |
} finally { |
|
42 |
requestTimer.setDuration(); |
|
43 |
} |
|
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()); |
|
44 | 34 |
} |
45 | 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(); |
|
46 | 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 |
|
|
47 | 56 |
} |
modules/dnet-openaire-exporter/trunk/pom.xml | ||
---|---|---|
368 | 368 |
<dependency> |
369 | 369 |
<groupId>net.bull.javamelody</groupId> |
370 | 370 |
<artifactId>javamelody-spring-boot-starter</artifactId> |
371 |
<version>1.71.0</version>
|
|
371 |
<version>${javamelody.version}</version>
|
|
372 | 372 |
</dependency> |
373 | 373 |
|
374 | 374 |
<dependency> |
... | ... | |
420 | 420 |
<apache.solr.version>7.1.0</apache.solr.version> |
421 | 421 |
<mongodb.driver.version>3.4.2</mongodb.driver.version> |
422 | 422 |
<springfox-version>2.7.0</springfox-version> |
423 |
<prometheus.version>0.0.25</prometheus.version> |
|
423 |
<prometheus.version>0.2.0</prometheus.version> |
|
424 |
<javamelody.version>1.71.0</javamelody.version> |
|
424 | 425 |
<maven.javadoc.failOnError>false</maven.javadoc.failOnError> |
425 | 426 |
<dockerfile-maven-version>1.3.6</dockerfile-maven-version> |
426 | 427 |
</properties> |
Also available in: Unified diff
updated prometheus client version, added more oap interceptors to track execution time