|
17 | 17 | package org.springframework.boot.actuate.autoconfigure.metrics.export.influx;
|
18 | 18 |
|
19 | 19 | import io.micrometer.core.instrument.Clock;
|
| 20 | +import io.micrometer.core.ipc.http.HttpUrlConnectionSender; |
20 | 21 | import io.micrometer.influx.InfluxConfig;
|
21 | 22 | import io.micrometer.influx.InfluxMeterRegistry;
|
22 | 23 |
|
|
38 | 39 | * {@link EnableAutoConfiguration Auto-configuration} for exporting metrics to Influx.
|
39 | 40 | *
|
40 | 41 | * @author Jon Schneider
|
| 42 | + * @author Artsiom Yudovin |
41 | 43 | * @since 2.0.0
|
42 | 44 | */
|
43 | 45 | @Configuration
|
|
50 | 52 | @EnableConfigurationProperties(InfluxProperties.class)
|
51 | 53 | public class InfluxMetricsExportAutoConfiguration {
|
52 | 54 |
|
| 55 | + private final InfluxProperties properties; |
| 56 | + |
| 57 | + public InfluxMetricsExportAutoConfiguration(InfluxProperties properties) { |
| 58 | + this.properties = properties; |
| 59 | + } |
| 60 | + |
53 | 61 | @Bean
|
54 | 62 | @ConditionalOnMissingBean
|
55 |
| - public InfluxConfig influxConfig(InfluxProperties influxProperties) { |
56 |
| - return new InfluxPropertiesConfigAdapter(influxProperties); |
| 63 | + public InfluxConfig influxConfig() { |
| 64 | + return new InfluxPropertiesConfigAdapter(this.properties); |
57 | 65 | }
|
58 | 66 |
|
59 | 67 | @Bean
|
60 | 68 | @ConditionalOnMissingBean
|
61 |
| - public InfluxMeterRegistry influxMeterRegistry(InfluxConfig influxConfig, |
62 |
| - Clock clock) { |
63 |
| - return new InfluxMeterRegistry(influxConfig, clock); |
| 69 | + public InfluxMeterRegistry influxMeterRegistry(InfluxConfig influxConfig, Clock clock, |
| 70 | + InfluxProperties influxProperties) { |
| 71 | + return InfluxMeterRegistry.builder(influxConfig).clock(clock) |
| 72 | + .httpClient( |
| 73 | + new HttpUrlConnectionSender(this.properties.getConnectTimeout(), |
| 74 | + this.properties.getReadTimeout())) |
| 75 | + .build(); |
| 76 | + |
64 | 77 | }
|
65 | 78 |
|
66 | 79 | }
|
0 commit comments