Applied suggestions

This commit is contained in:
Marcin Grzejszczak
2021-02-19 09:03:19 +01:00
parent 2e2a87e367
commit 41af6169e9
4 changed files with 32 additions and 22 deletions

View File

@@ -35,6 +35,11 @@ public class WavefrontProperties {
*/
private boolean enabled;
/**
* Span buffer maximum queue size.
*/
private int maxQueueSize = 50000;
/**
* Tags that should be associated with RED metrics. If the span has any of the
* specified tags, then those get reported to generated RED metrics.
@@ -49,6 +54,14 @@ public class WavefrontProperties {
this.redMetricsCustomTagKeys = redMetricsCustomTagKeys;
}
public int getMaxQueueSize() {
return this.maxQueueSize;
}
public void setMaxQueueSize(int maxQueueSize) {
this.maxQueueSize = maxQueueSize;
}
public boolean isEnabled() {
return this.enabled;
}

View File

@@ -52,24 +52,21 @@ import org.springframework.context.annotation.Configuration;
@ConditionalOnProperty(value = { "spring.sleuth.enabled", "spring.sleuth.wavefront.enabled" }, matchIfMissing = true)
public class WavefrontSleuthAutoConfiguration {
static final String BEAN_NAME = "wavefrontTracingCustomizer";
@Bean
@ConditionalOnBean({ MeterRegistry.class, WavefrontConfig.class, WavefrontSender.class, ApplicationTags.class })
WavefrontSleuthSpanHandler wavefrontSleuthSpanHandler(MeterRegistry meterRegistry, WavefrontSender wavefrontSender,
ApplicationTags applicationTags, WavefrontConfig wavefrontConfig, WavefrontProperties wavefrontProperties) {
return new WavefrontSleuthSpanHandler(
// https://github.com/wavefrontHQ/wavefront-opentracing-sdk-java/blob/f1f08d8daf7b692b9b61dcd5bc24ca6befa8e710/src/main/java/com/wavefront/opentracing/reporting/WavefrontSpanReporter.java#L54
50000, // TODO: maxQueueSize should be a property, ya?
wavefrontSender, meterRegistry, wavefrontConfig.source(), applicationTags,
wavefrontProperties.getRedMetricsCustomTagKeys());
wavefrontProperties.getMaxQueueSize(), wavefrontSender, meterRegistry, wavefrontConfig.source(),
applicationTags, wavefrontProperties.getRedMetricsCustomTagKeys());
}
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass({ Tracer.class, TracingCustomizer.class, SpanHandler.class })
static class BraveCustomizerConfiguration {
@Bean(BEAN_NAME)
@Bean
@ConditionalOnMissingBean(WavefrontTracingCustomizer.class)
@ConditionalOnBean({ MeterRegistry.class, WavefrontConfig.class, WavefrontSender.class })
WavefrontTracingCustomizer wavefrontTracingCustomizer(WavefrontSleuthSpanHandler spanHandler) {

View File

@@ -116,21 +116,21 @@ public final class WavefrontSleuthSpanHandler implements Runnable, Closeable {
private static final byte[] DECODING = buildDecodingArray();
final LinkedBlockingQueue<Pair<TraceContext, FinishedSpan>> spanBuffer;
private final LinkedBlockingQueue<Pair<TraceContext, FinishedSpan>> spanBuffer;
final WavefrontSender wavefrontSender;
private final WavefrontSender wavefrontSender;
final WavefrontInternalReporter wfInternalReporter;
private final WavefrontInternalReporter wfInternalReporter;
final Set<String> traceDerivedCustomTagKeys;
private final Set<String> traceDerivedCustomTagKeys;
final Counter spansDropped;
private final Counter spansDropped;
final Counter spansReceived;
private final Counter spansReceived;
final Counter reportErrors;
private final Counter reportErrors;
final Thread sendingThread;
private final Thread sendingThread;
private volatile boolean stop = false;
@@ -138,13 +138,13 @@ public final class WavefrontSleuthSpanHandler implements Runnable, Closeable {
private final ScheduledExecutorService heartbeatMetricsScheduledExecutorService;
final String source;
private final String source;
final List<Pair<String, String>> defaultTags;
private final List<Pair<String, String>> defaultTags;
final Set<String> defaultTagKeys;
private final Set<String> defaultTagKeys;
final ApplicationTags applicationTags;
private final ApplicationTags applicationTags;
WavefrontSleuthSpanHandler(int maxQueueSize, WavefrontSender wavefrontSender, MeterRegistry meterRegistry,
String source, ApplicationTags applicationTags, Set<String> redMetricsCustomTagKeys) {
@@ -265,6 +265,7 @@ public final class WavefrontSleuthSpanHandler implements Runnable, Closeable {
if (LOG.isDebugEnabled()) {
LOG.debug("error sending span " + context, t);
}
this.reportErrors.increment();
}
// report stats irrespective of span sampling.
@@ -281,6 +282,7 @@ public final class WavefrontSleuthSpanHandler implements Runnable, Closeable {
if (LOG.isDebugEnabled()) {
LOG.debug("error sending span RED metrics " + context, t);
}
this.reportErrors.increment();
}
}
}

View File

@@ -121,11 +121,10 @@ public class WavefrontTracingIntegrationTests {
SpanRecord spanRecord = takeRecord(spanRecordQueue);
// http
assertThat(spanRecord.tags).contains(Pair.of("http.status_code", "500"), Pair.of("error", "true") // retains
assertThat(spanRecord.tags).contains(Pair.of("http.status_code", "500"), Pair.of("error", "true")); // retains
// the
// boolean
// true
);
}
@Test
@@ -134,11 +133,10 @@ public class WavefrontTracingIntegrationTests {
SpanRecord spanRecord = takeRecord(spanRecordQueue);
// http
assertThat(spanRecord.tags).contains(Pair.of("http.status_code", "500"), Pair.of("error", "true") // deletes
assertThat(spanRecord.tags).contains(Pair.of("http.status_code", "500"), Pair.of("error", "true")); // deletes
// the
// user
// message
);
}
@Test