Trying to make this work
This commit is contained in:
@@ -242,7 +242,7 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>1.5.4.RELEASE</version>
|
||||
<version>2.0.0.BUILD-SNAPSHOT</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
|
||||
@@ -21,6 +21,11 @@
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.micrometer</groupId>
|
||||
<artifactId>micrometer-core</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||
|
||||
@@ -1,37 +1,31 @@
|
||||
package org.springframework.cloud.sleuth.metric;
|
||||
|
||||
import org.springframework.boot.actuate.metrics.CounterService;
|
||||
import io.micrometer.core.instrument.Counter;
|
||||
|
||||
/**
|
||||
* Service to operate on accepted and dropped spans statistics.
|
||||
* Operates on a {@link CounterService} underneath
|
||||
* Operates on a {@link Counter} underneath
|
||||
*
|
||||
* @author Marcin Grzejszczak
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class CounterServiceBasedSpanMetricReporter implements SpanMetricReporter {
|
||||
private final String acceptedSpansMetricName;
|
||||
private final String droppedSpansMetricName;
|
||||
private final CounterService counterService;
|
||||
private final Counter acceptedSpansCounter;
|
||||
private final Counter droppedSpansCounter;
|
||||
|
||||
public CounterServiceBasedSpanMetricReporter(String acceptedSpansMetricName,
|
||||
String droppedSpansMetricName, CounterService counterService) {
|
||||
this.acceptedSpansMetricName = acceptedSpansMetricName;
|
||||
this.droppedSpansMetricName = droppedSpansMetricName;
|
||||
this.counterService = counterService;
|
||||
public CounterServiceBasedSpanMetricReporter(Counter acceptedSpansCounter,
|
||||
Counter droppedSpansCounter) {
|
||||
this.acceptedSpansCounter = acceptedSpansCounter;
|
||||
this.droppedSpansCounter = droppedSpansCounter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void incrementAcceptedSpans(long quantity) {
|
||||
for (int i = 0; i < quantity; i++) {
|
||||
this.counterService.increment(this.acceptedSpansMetricName);
|
||||
}
|
||||
this.acceptedSpansCounter.increment(quantity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void incrementDroppedSpans(long quantity) {
|
||||
for (int i = 0; i < quantity; i++) {
|
||||
this.counterService.increment(this.droppedSpansMetricName);
|
||||
}
|
||||
this.droppedSpansCounter.increment(quantity);
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,6 @@ import java.lang.invoke.MethodHandles;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.boot.actuate.metrics.CounterService;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
@@ -34,6 +33,9 @@ import org.springframework.context.annotation.Conditional;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.type.AnnotatedTypeMetadata;
|
||||
|
||||
import io.micrometer.core.instrument.Counter;
|
||||
import io.micrometer.core.instrument.MeterRegistry;
|
||||
|
||||
/**
|
||||
* {@link org.springframework.boot.autoconfigure.EnableAutoConfiguration Auto-configuration}
|
||||
* enables Sleuth related metrics reporting
|
||||
@@ -53,19 +55,22 @@ public class TraceMetricsAutoConfiguration {
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnClass(CounterService.class)
|
||||
@ConditionalOnClass(Counter.class)
|
||||
@ConditionalOnMissingBean(SpanMetricReporter.class)
|
||||
protected static class CounterServiceSpanReporterConfig {
|
||||
@Bean
|
||||
@ConditionalOnBean(CounterService.class)
|
||||
public SpanMetricReporter spanReporterCounterService(CounterService counterService,
|
||||
SleuthMetricProperties sleuthMetricProperties) {
|
||||
return new CounterServiceBasedSpanMetricReporter(sleuthMetricProperties.getSpan().getAcceptedName(),
|
||||
sleuthMetricProperties.getSpan().getDroppedName(), counterService);
|
||||
@ConditionalOnBean(Counter.class)
|
||||
public SpanMetricReporter spanReporterCounterService(SleuthMetricProperties sleuthMetricProperties,
|
||||
MeterRegistry meterRegistry) {
|
||||
Counter acceptedSpansCounter = Counter.builder(
|
||||
sleuthMetricProperties.getSpan().getAcceptedName()).register(meterRegistry);
|
||||
Counter droppedSpansCounter = Counter.builder(
|
||||
sleuthMetricProperties.getSpan().getDroppedName()).register(meterRegistry);
|
||||
return new CounterServiceBasedSpanMetricReporter(acceptedSpansCounter, droppedSpansCounter);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(CounterService.class)
|
||||
@ConditionalOnMissingBean(Counter.class)
|
||||
public SpanMetricReporter noOpSpanReporterCounterService() {
|
||||
return new NoOpSpanMetricReporter();
|
||||
}
|
||||
@@ -78,6 +83,7 @@ public class TraceMetricsAutoConfiguration {
|
||||
return new NoOpSpanMetricReporter();
|
||||
}
|
||||
|
||||
// TODO: Remove this
|
||||
static class PickMetricIfMetricsIsMissing extends SpringBootCondition {
|
||||
|
||||
private static final Log log = LogFactory.getLog(MethodHandles.lookup().lookupClass());
|
||||
|
||||
@@ -15,7 +15,6 @@ ribbon.eureka.enabled: false
|
||||
spring.sleuth.scheduled.skipPattern: "^org.*TestBeanWithScheduledMethodToBeIgnored$"
|
||||
# comma separated list of matchers
|
||||
spring.sleuth.rxjava.schedulers.ignoredthreads: HystixMetricPoller,^MyCustomThread.*$,^RxComputation.*$
|
||||
security.ignored: /**
|
||||
|
||||
#disable hibernate by default
|
||||
spring.autoconfigure.exclude: org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration, org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration
|
||||
spring.autoconfigure.exclude: org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration, org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration, org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration
|
||||
Reference in New Issue
Block a user