Revision 48733
Added by Claudio Atzori about 7 years ago
modules/dnet-openaire-exporter/trunk/dnet-openaire-exporter.iml | ||
---|---|---|
150 | 150 |
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-metadata:1.2.0.RELEASE" level="project" /> |
151 | 151 |
<orderEntry type="library" name="Maven: org.mapstruct:mapstruct:1.1.0.Final" level="project" /> |
152 | 152 |
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger-ui:2.7.0" level="project" /> |
153 |
<orderEntry type="library" name="Maven: io.prometheus:simpleclient_spring_boot:0.0.25" level="project" /> |
|
154 |
<orderEntry type="library" name="Maven: io.prometheus:simpleclient:0.0.25" level="project" /> |
|
155 |
<orderEntry type="library" name="Maven: io.prometheus:simpleclient_common:0.0.25" level="project" /> |
|
156 |
<orderEntry type="library" name="Maven: io.prometheus:simpleclient_spring_web:0.0.25" level="project" /> |
|
157 |
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-actuator:1.5.2.RELEASE" level="project" /> |
|
158 |
<orderEntry type="library" name="Maven: io.prometheus:simpleclient_hotspot:0.0.25" level="project" /> |
|
159 |
<orderEntry type="library" name="Maven: io.prometheus:simpleclient_servlet:0.0.25" level="project" /> |
|
153 | 160 |
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-starter-test:1.5.2.RELEASE" level="project" /> |
154 | 161 |
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test:1.5.2.RELEASE" level="project" /> |
155 | 162 |
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:1.5.2.RELEASE" level="project" /> |
modules/dnet-openaire-exporter/trunk/src/main/java/eu/dnetlib/openaire/exporter/aop/DatasourceApiProfiler.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 |
/** |
|
10 |
* Created by claudio on 25/07/2017. |
|
11 |
*/ |
|
12 |
@Aspect |
|
13 |
@Component |
|
14 |
public class DatasourceApiProfiler { |
|
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()") |
|
19 |
.register(); |
|
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 |
} |
|
29 |
} |
|
30 |
|
|
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()") |
|
34 |
.register(); |
|
35 |
|
|
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 |
} |
|
44 |
} |
|
45 |
|
|
46 |
|
|
47 |
} |
modules/dnet-openaire-exporter/trunk/src/main/java/eu/dnetlib/openaire/exporter/datasource/clients/DatasourceDao.java | ||
---|---|---|
160 | 160 |
}; |
161 | 161 |
} |
162 | 162 |
|
163 |
public ClientResponse getInfo(final String dsId) {
|
|
163 |
public ClientResponse getDsById(final String dsId) {
|
|
164 | 164 |
|
165 | 165 |
final CountDownLatch outerLatch = new CountDownLatch(3); |
166 | 166 |
final Queue<Throwable> errors = new ConcurrentLinkedQueue<>(); |
modules/dnet-openaire-exporter/trunk/src/main/java/eu/dnetlib/openaire/exporter/datasource/DatasourcesApiController.java | ||
---|---|---|
43 | 43 |
log.debug(String.format("getDatasourceInfo(dsId = %s)", id)); |
44 | 44 |
} |
45 | 45 |
|
46 |
final ClientResponse clientResponse = dsDao.getInfo(id);
|
|
46 |
final ClientResponse clientResponse = dsDao.getDsById(id);
|
|
47 | 47 |
return clientResponse.getDatasourceResponse(); |
48 | 48 |
} |
49 | 49 |
|
modules/dnet-openaire-exporter/trunk/src/main/java/eu/dnetlib/DNetOpenaireExporterBeanFactory.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib; |
2 | 2 |
|
3 |
import java.util.Collection; |
|
4 |
|
|
3 | 5 |
import com.mongodb.MongoClient; |
4 | 6 |
import com.mongodb.MongoClientOptions; |
5 | 7 |
import com.mongodb.ServerAddress; |
6 | 8 |
import eu.dnetlib.OpenaireExporterConfig.Jdbc; |
7 | 9 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; |
10 |
import io.prometheus.client.exporter.MetricsServlet; |
|
11 |
import io.prometheus.client.hotspot.DefaultExports; |
|
12 |
import io.prometheus.client.spring.boot.SpringBootMetricsCollector; |
|
8 | 13 |
import org.apache.commons.dbcp2.BasicDataSource; |
9 | 14 |
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean; |
10 | 15 |
import org.springframework.beans.factory.annotation.Autowired; |
16 |
import org.springframework.beans.factory.annotation.Value; |
|
17 |
import org.springframework.boot.actuate.endpoint.PublicMetrics; |
|
18 |
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; |
|
19 |
import org.springframework.boot.web.servlet.ServletRegistrationBean; |
|
11 | 20 |
import org.springframework.context.annotation.Bean; |
12 | 21 |
import org.springframework.context.annotation.Configuration; |
13 | 22 |
|
... | ... | |
59 | 68 |
} |
60 | 69 |
|
61 | 70 |
|
71 |
@Bean |
|
72 |
@ConditionalOnMissingBean(SpringBootMetricsCollector.class) |
|
73 |
SpringBootMetricsCollector springBootMetricsCollector(final Collection<PublicMetrics> publicMetrics) { |
|
74 |
|
|
75 |
final SpringBootMetricsCollector springBootMetricsCollector = new SpringBootMetricsCollector(publicMetrics); |
|
76 |
springBootMetricsCollector.register(); |
|
77 |
|
|
78 |
return springBootMetricsCollector; |
|
79 |
} |
|
80 |
|
|
81 |
@Bean |
|
82 |
@ConditionalOnMissingBean(name = "prometheusMetricsServletRegistrationBean") |
|
83 |
ServletRegistrationBean prometheusMetricsServletRegistrationBean(@Value("${prometheus.metrics.path:/prometheus}") final String metricsPath) { |
|
84 |
DefaultExports.initialize(); |
|
85 |
return new ServletRegistrationBean(new MetricsServlet(), metricsPath); |
|
86 |
} |
|
87 |
|
|
88 |
|
|
62 | 89 |
} |
modules/dnet-openaire-exporter/trunk/src/main/java/eu/dnetlib/DNetOpenaireExporterApplication.java | ||
---|---|---|
13 | 13 |
import org.springframework.boot.SpringApplication; |
14 | 14 |
import org.springframework.boot.autoconfigure.SpringBootApplication; |
15 | 15 |
import org.springframework.cache.annotation.EnableCaching; |
16 |
import org.springframework.context.annotation.EnableAspectJAutoProxy; |
|
16 | 17 |
import org.springframework.web.bind.annotation.RequestMapping; |
17 | 18 |
import org.springframework.web.bind.annotation.RequestMethod; |
18 | 19 |
import org.springframework.web.bind.annotation.RestController; |
... | ... | |
21 | 22 |
@EnableCaching |
22 | 23 |
@RestController |
23 | 24 |
@SpringBootApplication |
25 |
@EnableAspectJAutoProxy |
|
24 | 26 |
public class DNetOpenaireExporterApplication { |
25 | 27 |
|
26 | 28 |
private static final Log log = LogFactory.getLog(DNetOpenaireExporterApplication.class); |
modules/dnet-openaire-exporter/trunk/src/main/resources/application.properties | ||
---|---|---|
4 | 4 |
services.is.host = localhost |
5 | 5 |
services.is.port = 8280 |
6 | 6 |
services.is.baseurl = http://${services.is.host}:${services.is.port}/${services.is.context}/services |
7 |
services.is.context = is
|
|
7 |
services.is.context = app
|
|
8 | 8 |
server.port=8080 |
9 | 9 |
|
10 | 10 |
spring.datasource.driverClassName = org.postgresql.Driver |
modules/dnet-openaire-exporter/trunk/pom.xml | ||
---|---|---|
180 | 180 |
<version>${springfox-version}</version> |
181 | 181 |
</dependency> |
182 | 182 |
|
183 |
<!-- for /metrics and /health controllers --> |
|
183 | 184 |
<dependency> |
185 |
<groupId>io.prometheus</groupId> |
|
186 |
<artifactId>simpleclient_spring_boot</artifactId> |
|
187 |
<version>${prometheus.version}</version> |
|
188 |
<exclusions> |
|
189 |
<exclusion> |
|
190 |
<groupId>org.springframework</groupId> |
|
191 |
<artifactId>spring-web</artifactId> |
|
192 |
</exclusion> |
|
193 |
</exclusions> |
|
194 |
</dependency> |
|
195 |
<dependency> |
|
196 |
<groupId>io.prometheus</groupId> |
|
197 |
<artifactId>simpleclient_hotspot</artifactId> |
|
198 |
<version>${prometheus.version}</version> |
|
199 |
</dependency> |
|
200 |
<dependency> |
|
201 |
<groupId>io.prometheus</groupId> |
|
202 |
<artifactId>simpleclient_servlet</artifactId> |
|
203 |
<version>${prometheus.version}</version> |
|
204 |
</dependency> |
|
205 |
|
|
206 |
<dependency> |
|
184 | 207 |
<groupId>org.springframework.boot</groupId> |
185 | 208 |
<artifactId>spring-boot-starter-test</artifactId> |
186 | 209 |
<scope>test</scope> |
... | ... | |
204 | 227 |
<java.version>1.8</java.version> |
205 | 228 |
<mongodb.driver.version>3.4.2</mongodb.driver.version> |
206 | 229 |
<springfox-version>2.7.0</springfox-version> |
230 |
<prometheus.version>0.0.25</prometheus.version> |
|
207 | 231 |
<maven.javadoc.failOnError>false</maven.javadoc.failOnError> |
208 | 232 |
</properties> |
209 | 233 |
</project> |
Also available in: Unified diff
added app monitoring with prometheus, first metrics available for basic search operations