Applied checkstyle
This commit is contained in:
@@ -15,8 +15,9 @@
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>spring-cloud-sleuth-core</artifactId>
|
||||
@@ -334,10 +335,10 @@
|
||||
</dependency>
|
||||
<!-- This forces the guava version to 20 within the test scope, which is required by GRPC -->
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>20.0</version>
|
||||
<scope>test</scope>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>20.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -45,6 +45,14 @@ import org.springframework.core.annotation.AnnotationUtils;
|
||||
*/
|
||||
public class DefaultSpanNamer implements SpanNamer {
|
||||
|
||||
private static boolean isDefaultToString(Object delegate, String spanName) {
|
||||
if (delegate instanceof Method) {
|
||||
return delegate.toString().equals(spanName);
|
||||
}
|
||||
return (delegate.getClass().getName() + "@"
|
||||
+ Integer.toHexString(delegate.hashCode())).equals(spanName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name(Object object, String defaultValue) {
|
||||
SpanName annotation = annotation(object);
|
||||
@@ -63,12 +71,4 @@ public class DefaultSpanNamer implements SpanNamer {
|
||||
return AnnotationUtils.findAnnotation(o.getClass(), SpanName.class);
|
||||
}
|
||||
|
||||
private static boolean isDefaultToString(Object delegate, String spanName) {
|
||||
if (delegate instanceof Method) {
|
||||
return delegate.toString().equals(spanName);
|
||||
}
|
||||
return (delegate.getClass().getName() + "@"
|
||||
+ Integer.toHexString(delegate.hashCode())).equals(spanName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,12 +21,13 @@ import brave.Tracer;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
|
||||
/**
|
||||
* Sleuth annotation processor
|
||||
* Sleuth annotation processor.
|
||||
*
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,7 +31,7 @@ import java.lang.annotation.Target;
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Inherited
|
||||
@Target(value = { ElementType.METHOD })
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface ContinueSpan {
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,12 +13,14 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.sleuth.annotation;
|
||||
|
||||
import brave.SpanCustomizer;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.cloud.sleuth.util.SpanNameUtil;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.sleuth.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
@@ -38,7 +39,7 @@ import org.springframework.core.annotation.AliasFor;
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Inherited
|
||||
@Target(value = { ElementType.METHOD })
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface NewSpan {
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,9 +29,9 @@ public interface NewSpanParser {
|
||||
|
||||
/**
|
||||
* Override to control the name and tags on an annotation-based span.
|
||||
* @param methodInvocation
|
||||
* @param newSpan
|
||||
* @param span
|
||||
* @param methodInvocation method invocation annotated with new span
|
||||
* @param newSpan meta data of the new span
|
||||
* @param span span to customize
|
||||
*/
|
||||
void parse(MethodInvocation methodInvocation, NewSpan newSpan, SpanCustomizer span);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,6 +19,7 @@ package org.springframework.cloud.sleuth.annotation;
|
||||
import brave.Span;
|
||||
import brave.Tracer;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -45,10 +45,10 @@ import org.springframework.util.StringUtils;
|
||||
class ReactorSleuthMethodInvocationProcessor
|
||||
extends AbstractSleuthMethodInvocationProcessor {
|
||||
|
||||
private NonReactorSleuthMethodInvocationProcessor nonReactorSleuthMethodInvocationProcessor;
|
||||
|
||||
Tracing tracing;
|
||||
|
||||
private NonReactorSleuthMethodInvocationProcessor nonReactorSleuthMethodInvocationProcessor;
|
||||
|
||||
Tracing tracing() {
|
||||
if (this.tracing == null) {
|
||||
this.tracing = this.beanFactory.getBean(Tracing.class);
|
||||
@@ -100,6 +100,19 @@ class ReactorSleuthMethodInvocationProcessor
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isReactorReturnType(Class<?> returnType) {
|
||||
return Flux.class.equals(returnType) || Mono.class.equals(returnType);
|
||||
}
|
||||
|
||||
private NonReactorSleuthMethodInvocationProcessor nonReactorSleuthMethodInvocationProcessor() {
|
||||
if (this.nonReactorSleuthMethodInvocationProcessor == null) {
|
||||
this.nonReactorSleuthMethodInvocationProcessor = new NonReactorSleuthMethodInvocationProcessor();
|
||||
this.nonReactorSleuthMethodInvocationProcessor
|
||||
.setBeanFactory(this.beanFactory);
|
||||
}
|
||||
return this.nonReactorSleuthMethodInvocationProcessor;
|
||||
}
|
||||
|
||||
private static final class FluxSpan extends FluxOperator<Object, Object> {
|
||||
|
||||
final Span span;
|
||||
@@ -307,17 +320,4 @@ class ReactorSleuthMethodInvocationProcessor
|
||||
|
||||
}
|
||||
|
||||
private boolean isReactorReturnType(Class<?> returnType) {
|
||||
return Flux.class.equals(returnType) || Mono.class.equals(returnType);
|
||||
}
|
||||
|
||||
private NonReactorSleuthMethodInvocationProcessor nonReactorSleuthMethodInvocationProcessor() {
|
||||
if (this.nonReactorSleuthMethodInvocationProcessor == null) {
|
||||
this.nonReactorSleuthMethodInvocationProcessor = new NonReactorSleuthMethodInvocationProcessor();
|
||||
this.nonReactorSleuthMethodInvocationProcessor
|
||||
.setBeanFactory(this.beanFactory);
|
||||
}
|
||||
return this.nonReactorSleuthMethodInvocationProcessor;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,10 +19,12 @@ package org.springframework.cloud.sleuth.annotation;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.aopalliance.aop.Advice;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
|
||||
import org.springframework.aop.ClassFilter;
|
||||
import org.springframework.aop.IntroductionInterceptor;
|
||||
import org.springframework.aop.Pointcut;
|
||||
@@ -87,6 +89,34 @@ class SleuthAdvisorConfig extends AbstractPointcutAdvisor implements BeanFactory
|
||||
return new AnnotationClassOrMethodOrArgsPointcut();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a method is properly annotated with a given Sleuth annotation.
|
||||
*/
|
||||
private static class AnnotationMethodsResolver {
|
||||
|
||||
private final Class<? extends Annotation> annotationType;
|
||||
|
||||
AnnotationMethodsResolver(Class<? extends Annotation> annotationType) {
|
||||
this.annotationType = annotationType;
|
||||
}
|
||||
|
||||
boolean hasAnnotatedMethods(Class<?> clazz) {
|
||||
final AtomicBoolean found = new AtomicBoolean(false);
|
||||
ReflectionUtils.doWithMethods(clazz, (method -> {
|
||||
if (found.get()) {
|
||||
return;
|
||||
}
|
||||
Annotation annotation = AnnotationUtils.findAnnotation(method,
|
||||
AnnotationMethodsResolver.this.annotationType);
|
||||
if (annotation != null) {
|
||||
found.set(true);
|
||||
}
|
||||
}));
|
||||
return found.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a class or a method is is annotated with Sleuth related annotations.
|
||||
*/
|
||||
@@ -130,34 +160,6 @@ class SleuthAdvisorConfig extends AbstractPointcutAdvisor implements BeanFactory
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a method is properly annotated with a given Sleuth annotation.
|
||||
*/
|
||||
private static class AnnotationMethodsResolver {
|
||||
|
||||
private final Class<? extends Annotation> annotationType;
|
||||
|
||||
AnnotationMethodsResolver(Class<? extends Annotation> annotationType) {
|
||||
this.annotationType = annotationType;
|
||||
}
|
||||
|
||||
boolean hasAnnotatedMethods(Class<?> clazz) {
|
||||
final AtomicBoolean found = new AtomicBoolean(false);
|
||||
ReflectionUtils.doWithMethods(clazz, (method -> {
|
||||
if (found.get()) {
|
||||
return;
|
||||
}
|
||||
Annotation annotation = AnnotationUtils.findAnnotation(method,
|
||||
AnnotationMethodsResolver.this.annotationType);
|
||||
if (annotation != null) {
|
||||
found.set(true);
|
||||
}
|
||||
}));
|
||||
return found.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.sleuth.annotation;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,9 +13,11 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.sleuth.annotation;
|
||||
|
||||
import brave.Tracing;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,6 +23,7 @@ import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
|
||||
/**
|
||||
@@ -32,14 +33,14 @@ import org.springframework.core.annotation.AnnotationUtils;
|
||||
* @author Christian Schwerdtfeger
|
||||
* @since 1.2.0
|
||||
*/
|
||||
class SleuthAnnotationUtils {
|
||||
final class SleuthAnnotationUtils {
|
||||
|
||||
private static final Log log = LogFactory.getLog(SleuthAnnotationUtils.class);
|
||||
|
||||
private SleuthAnnotationUtils() {
|
||||
|
||||
}
|
||||
|
||||
private static final Log log = LogFactory.getLog(SleuthAnnotationUtils.class);
|
||||
|
||||
static boolean isMethodAnnotated(Method method) {
|
||||
return findAnnotation(method, NewSpan.class) != null
|
||||
|| findAnnotation(method, ContinueSpan.class) != null;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -40,7 +40,7 @@ import org.springframework.core.annotation.AliasFor;
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Inherited
|
||||
@Target(value = { ElementType.PARAMETER })
|
||||
@Target(ElementType.PARAMETER)
|
||||
public @interface SpanTag {
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -24,6 +24,7 @@ import brave.SpanCustomizer;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.aop.support.AopUtils;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,6 +18,7 @@ package org.springframework.cloud.sleuth.annotation;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.expression.ExpressionParser;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -38,7 +38,6 @@ import zipkin2.reporter.InMemoryReporterMetrics;
|
||||
import zipkin2.reporter.Reporter;
|
||||
import zipkin2.reporter.ReporterMetrics;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
@@ -49,6 +48,7 @@ import org.springframework.cloud.sleuth.SpanAdjuster;
|
||||
import org.springframework.cloud.sleuth.SpanNamer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -110,66 +110,6 @@ public class TraceAutoConfiguration {
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
private static class CompositeReporter implements Reporter<zipkin2.Span> {
|
||||
|
||||
private static final Log log = LogFactory.getLog(CompositeReporter.class);
|
||||
|
||||
private final List<SpanAdjuster> spanAdjusters;
|
||||
|
||||
private final Reporter<zipkin2.Span> spanReporter;
|
||||
|
||||
private CompositeReporter(List<SpanAdjuster> spanAdjusters,
|
||||
List<Reporter<Span>> spanReporters) {
|
||||
this.spanAdjusters = spanAdjusters;
|
||||
this.spanReporter = spanReporters.size() == 1 ? spanReporters.get(0)
|
||||
: new ListReporter(spanReporters);
|
||||
}
|
||||
|
||||
private static class ListReporter implements Reporter<zipkin2.Span> {
|
||||
|
||||
private final List<Reporter<Span>> spanReporters;
|
||||
|
||||
private ListReporter(List<Reporter<Span>> spanReporters) {
|
||||
this.spanReporters = spanReporters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void report(Span span) {
|
||||
for (Reporter<zipkin2.Span> spanReporter : this.spanReporters) {
|
||||
try {
|
||||
spanReporter.report(span);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
log.warn("Exception occurred while trying to report the span "
|
||||
+ span, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ListReporter{" + "spanReporters=" + this.spanReporters + '}';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void report(Span span) {
|
||||
Span spanToAdjust = span;
|
||||
for (SpanAdjuster spanAdjuster : this.spanAdjusters) {
|
||||
spanToAdjust = spanAdjuster.adjust(spanToAdjust);
|
||||
}
|
||||
this.spanReporter.report(spanToAdjust);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CompositeReporter{" + "spanAdjusters=" + this.spanAdjusters
|
||||
+ ", spanReporters=" + this.spanReporter + '}';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Bean(name = TRACER_BEAN_NAME)
|
||||
@ConditionalOnMissingBean
|
||||
Tracer tracer(Tracing tracing) {
|
||||
@@ -257,4 +197,64 @@ public class TraceAutoConfiguration {
|
||||
return CurrentSpanCustomizer.create(tracing);
|
||||
}
|
||||
|
||||
private static final class CompositeReporter implements Reporter<zipkin2.Span> {
|
||||
|
||||
private static final Log log = LogFactory.getLog(CompositeReporter.class);
|
||||
|
||||
private final List<SpanAdjuster> spanAdjusters;
|
||||
|
||||
private final Reporter<zipkin2.Span> spanReporter;
|
||||
|
||||
private CompositeReporter(List<SpanAdjuster> spanAdjusters,
|
||||
List<Reporter<Span>> spanReporters) {
|
||||
this.spanAdjusters = spanAdjusters;
|
||||
this.spanReporter = spanReporters.size() == 1 ? spanReporters.get(0)
|
||||
: new ListReporter(spanReporters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void report(Span span) {
|
||||
Span spanToAdjust = span;
|
||||
for (SpanAdjuster spanAdjuster : this.spanAdjusters) {
|
||||
spanToAdjust = spanAdjuster.adjust(spanToAdjust);
|
||||
}
|
||||
this.spanReporter.report(spanToAdjust);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CompositeReporter{" + "spanAdjusters=" + this.spanAdjusters
|
||||
+ ", spanReporters=" + this.spanReporter + '}';
|
||||
}
|
||||
|
||||
private static final class ListReporter implements Reporter<zipkin2.Span> {
|
||||
|
||||
private final List<Reporter<Span>> spanReporters;
|
||||
|
||||
private ListReporter(List<Reporter<Span>> spanReporters) {
|
||||
this.spanReporters = spanReporters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void report(Span span) {
|
||||
for (Reporter<zipkin2.Span> spanReporter : this.spanReporters) {
|
||||
try {
|
||||
spanReporter.report(span);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
log.warn("Exception occurred while trying to report the span "
|
||||
+ span, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ListReporter{" + "spanReporters=" + this.spanReporters + '}';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -48,8 +48,8 @@ public class TraceEnvironmentPostProcessor implements EnvironmentPostProcessor {
|
||||
// traces in logs without having to configure it.
|
||||
if (Boolean
|
||||
.parseBoolean(environment.getProperty("spring.sleuth.enabled", "true"))) {
|
||||
map.put("logging.pattern.level",
|
||||
"%5p [${spring.zipkin.service.name:${spring.application.name:-}},%X{X-B3-TraceId:-},%X{X-B3-SpanId:-},%X{X-Span-Export:-}]");
|
||||
map.put("logging.pattern.level", "%5p [${spring.zipkin.service.name:"
|
||||
+ "${spring.application.name:-}},%X{X-B3-TraceId:-},%X{X-B3-SpanId:-},%X{X-Span-Export:-}]");
|
||||
}
|
||||
addOrReplace(environment.getPropertySources(), map);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -32,10 +32,10 @@ import org.springframework.context.event.SmartApplicationListener;
|
||||
|
||||
class ContextRefreshedListener extends AtomicBoolean implements SmartApplicationListener {
|
||||
|
||||
private static final Log log = LogFactory.getLog(ContextRefreshedListener.class);
|
||||
|
||||
static final Map<BeanFactory, ContextRefreshedListener> CACHE = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Log log = LogFactory.getLog(ContextRefreshedListener.class);
|
||||
|
||||
ContextRefreshedListener(boolean initialValue) {
|
||||
super(initialValue);
|
||||
}
|
||||
@@ -44,6 +44,10 @@ class ContextRefreshedListener extends AtomicBoolean implements SmartApplication
|
||||
this(false);
|
||||
}
|
||||
|
||||
static ContextRefreshedListener getBean(BeanFactory beanFactory) {
|
||||
return CACHE.getOrDefault(beanFactory, new ContextRefreshedListener(false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsEventType(Class<? extends ApplicationEvent> eventType) {
|
||||
return ContextRefreshedEvent.class.isAssignableFrom(eventType);
|
||||
@@ -67,8 +71,4 @@ class ContextRefreshedListener extends AtomicBoolean implements SmartApplication
|
||||
}
|
||||
}
|
||||
|
||||
static ContextRefreshedListener getBean(BeanFactory beanFactory) {
|
||||
return CACHE.getOrDefault(beanFactory, new ContextRefreshedListener(false));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -27,7 +27,11 @@ import org.springframework.beans.factory.BeanFactory;
|
||||
* @author Marcin Grzejszczak
|
||||
* @since 2.1.0
|
||||
*/
|
||||
class ContextUtil {
|
||||
final class ContextUtil {
|
||||
|
||||
private ContextUtil() {
|
||||
throw new IllegalStateException("Can't instantiate a utility class");
|
||||
}
|
||||
|
||||
private static final Log log = LogFactory.getLog(ContextUtil.class);
|
||||
|
||||
@@ -39,4 +43,4 @@ class ContextUtil {
|
||||
return !contextRefreshed;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,7 +28,7 @@ import org.springframework.cloud.sleuth.DefaultSpanNamer;
|
||||
import org.springframework.cloud.sleuth.SpanNamer;
|
||||
|
||||
/**
|
||||
* {@link Executor} that wraps {@link Runnable} in a trace representation
|
||||
* {@link Executor} that wraps {@link Runnable} in a trace representation.
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @since 1.0.0
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -35,7 +35,7 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.util.concurrent.ListenableFuture;
|
||||
|
||||
/**
|
||||
* Trace representation of {@link ThreadPoolTaskExecutor}
|
||||
* Trace representation of {@link ThreadPoolTaskExecutor}.
|
||||
*
|
||||
* @author Marcin Grzejszczak
|
||||
* @since 1.0.10
|
||||
@@ -108,11 +108,6 @@ public class LazyTraceThreadPoolTaskExecutor extends ThreadPoolTaskExecutor {
|
||||
this.delegate.setThreadFactory(threadFactory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setThreadNamePrefix(String threadNamePrefix) {
|
||||
this.delegate.setThreadNamePrefix(threadNamePrefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRejectedExecutionHandler(
|
||||
RejectedExecutionHandler rejectedExecutionHandler) {
|
||||
@@ -185,8 +180,8 @@ public class LazyTraceThreadPoolTaskExecutor extends ThreadPoolTaskExecutor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setThreadPriority(int threadPriority) {
|
||||
this.delegate.setThreadPriority(threadPriority);
|
||||
public void setThreadNamePrefix(String threadNamePrefix) {
|
||||
this.delegate.setThreadNamePrefix(threadNamePrefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -195,8 +190,8 @@ public class LazyTraceThreadPoolTaskExecutor extends ThreadPoolTaskExecutor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDaemon(boolean daemon) {
|
||||
this.delegate.setDaemon(daemon);
|
||||
public void setThreadPriority(int threadPriority) {
|
||||
this.delegate.setThreadPriority(threadPriority);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -205,13 +200,13 @@ public class LazyTraceThreadPoolTaskExecutor extends ThreadPoolTaskExecutor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setThreadGroupName(String name) {
|
||||
this.delegate.setThreadGroupName(name);
|
||||
public void setDaemon(boolean daemon) {
|
||||
this.delegate.setDaemon(daemon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setThreadGroup(ThreadGroup threadGroup) {
|
||||
this.delegate.setThreadGroup(threadGroup);
|
||||
public void setThreadGroupName(String name) {
|
||||
this.delegate.setThreadGroupName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -220,13 +215,13 @@ public class LazyTraceThreadPoolTaskExecutor extends ThreadPoolTaskExecutor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Thread createThread(Runnable runnable) {
|
||||
return this.delegate.createThread(runnable);
|
||||
public void setThreadGroup(ThreadGroup threadGroup) {
|
||||
this.delegate.setThreadGroup(threadGroup);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCorePoolSize(int corePoolSize) {
|
||||
this.delegate.setCorePoolSize(corePoolSize);
|
||||
public Thread createThread(Runnable runnable) {
|
||||
return this.delegate.createThread(runnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -235,8 +230,8 @@ public class LazyTraceThreadPoolTaskExecutor extends ThreadPoolTaskExecutor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxPoolSize(int maxPoolSize) {
|
||||
this.delegate.setMaxPoolSize(maxPoolSize);
|
||||
public void setCorePoolSize(int corePoolSize) {
|
||||
this.delegate.setCorePoolSize(corePoolSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -245,8 +240,8 @@ public class LazyTraceThreadPoolTaskExecutor extends ThreadPoolTaskExecutor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setKeepAliveSeconds(int keepAliveSeconds) {
|
||||
this.delegate.setKeepAliveSeconds(keepAliveSeconds);
|
||||
public void setMaxPoolSize(int maxPoolSize) {
|
||||
this.delegate.setMaxPoolSize(maxPoolSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -254,6 +249,11 @@ public class LazyTraceThreadPoolTaskExecutor extends ThreadPoolTaskExecutor {
|
||||
return this.delegate.getKeepAliveSeconds();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setKeepAliveSeconds(int keepAliveSeconds) {
|
||||
this.delegate.setKeepAliveSeconds(keepAliveSeconds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setQueueCapacity(int queueCapacity) {
|
||||
this.delegate.setQueueCapacity(queueCapacity);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -24,6 +24,7 @@ import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
|
||||
import org.springframework.cloud.sleuth.SpanNamer;
|
||||
import org.springframework.cloud.sleuth.util.SpanNameUtil;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,6 +20,7 @@ import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import brave.Tracing;
|
||||
|
||||
import org.springframework.core.task.AsyncListenableTaskExecutor;
|
||||
import org.springframework.util.concurrent.ListenableFuture;
|
||||
|
||||
@@ -27,8 +28,8 @@ import org.springframework.util.concurrent.ListenableFuture;
|
||||
* AsyncListenableTaskExecutor that wraps all Runnable / Callable tasks into their trace
|
||||
* related representation.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Marcin Grzejszczak
|
||||
* @since 1.0.0
|
||||
* @see brave.propagation.CurrentTraceContext#wrap(Runnable)
|
||||
* @see brave.propagation.CurrentTraceContext#wrap(Callable)
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,15 +22,16 @@ import brave.ScopedSpan;
|
||||
import brave.Tracer;
|
||||
import brave.Tracing;
|
||||
import brave.propagation.TraceContext;
|
||||
|
||||
import org.springframework.cloud.sleuth.SpanNamer;
|
||||
|
||||
/**
|
||||
* Callable that passes Span between threads. The Span name is taken either from the
|
||||
* passed value or from the {@link SpanNamer} interface.
|
||||
*
|
||||
* @param <V> - return type from callable
|
||||
* @author Spencer Gibb
|
||||
* @author Marcin Grzejszczak
|
||||
* @param <V> - return type from callable
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class TraceCallable<V> implements Callable<V> {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,6 +20,7 @@ import brave.ScopedSpan;
|
||||
import brave.Tracer;
|
||||
import brave.Tracing;
|
||||
import brave.propagation.TraceContext;
|
||||
|
||||
import org.springframework.cloud.sleuth.SpanNamer;
|
||||
|
||||
/**
|
||||
@@ -33,7 +34,8 @@ import org.springframework.cloud.sleuth.SpanNamer;
|
||||
public class TraceRunnable implements Runnable {
|
||||
|
||||
/**
|
||||
* Since we don't know the exact operation name we provide a default name for the Span
|
||||
* Since we don't know the exact operation name we provide a default name for the
|
||||
* Span.
|
||||
*/
|
||||
private static final String DEFAULT_SPAN_NAME = "async";
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.sleuth.instrument.async;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -31,7 +32,7 @@ import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.cloud.sleuth.SpanNamer;
|
||||
|
||||
/**
|
||||
* A decorator class for {@link ExecutorService} to support tracing in Executors
|
||||
* A decorator class for {@link ExecutorService} to support tracing in Executors.
|
||||
*
|
||||
* @author Gaurav Rai Mazra
|
||||
* @since 1.0.0
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -25,7 +25,7 @@ import java.util.concurrent.TimeUnit;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
|
||||
/**
|
||||
* A decorator class for {@link ScheduledExecutorService} to support tracing in Executors
|
||||
* A decorator class for {@link ScheduledExecutorService} to support tracing in Executors.
|
||||
*
|
||||
* @author Gaurav Rai Mazra
|
||||
* @since 1.0.0
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018 the original author or authors.
|
||||
* Copyright 2018-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,10 +22,14 @@ import io.grpc.ManagedChannelBuilder;
|
||||
* Callback interface that can be implemented by beans wishing to further customize the
|
||||
* {@link io.grpc.ManagedChannelBuilder} via the {@link SpringAwareManagedChannelBuilder}.
|
||||
*
|
||||
* @author tyler.vangorder
|
||||
* @author Tyler Van Gorder
|
||||
*/
|
||||
public interface GrpcManagedChannelBuilderCustomizer {
|
||||
|
||||
/**
|
||||
* Customizes the channel builder.
|
||||
* @param managedChannelBuilder the builder to customize
|
||||
*/
|
||||
void customize(ManagedChannelBuilder<?> managedChannelBuilder);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -33,7 +33,7 @@ import io.grpc.inprocess.InProcessChannelBuilder;
|
||||
* grpc-spring-boot-starter or a new project could be created
|
||||
* "spring-grpc"/"spring-cloud-grpc"?
|
||||
*
|
||||
* @author tyler.vangorder
|
||||
* @author Tyler Van Gorder
|
||||
*/
|
||||
public class SpringAwareManagedChannelBuilder {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -37,7 +37,7 @@ import org.springframework.context.annotation.Bean;
|
||||
* This configuration is only enabled when both grpc-spring-boot-starter and
|
||||
* brave-instrumentation-grpc are on the classpath.
|
||||
*
|
||||
* @author tyler.vangorder
|
||||
* @author Tyler Van Gorder
|
||||
*/
|
||||
@ConditionalOnClass({ GrpcTracing.class, GRpcGlobalInterceptor.class })
|
||||
@ConditionalOnProperty(value = "spring.sleuth.grpc.enabled", matchIfMissing = true)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018 the original author or authors.
|
||||
* Copyright 2018-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,7 +20,7 @@ import brave.grpc.GrpcTracing;
|
||||
import io.grpc.ManagedChannelBuilder;
|
||||
|
||||
/**
|
||||
* @author tyler.vangorder
|
||||
* @author Tyler Van Gorder
|
||||
*/
|
||||
public class TracingManagedChannelBuilderCustomizer
|
||||
implements GrpcManagedChannelBuilderCustomizer {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,6 +18,7 @@ package org.springframework.cloud.sleuth.instrument.hystrix;
|
||||
|
||||
import brave.Tracing;
|
||||
import com.netflix.hystrix.HystrixCommand;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -35,6 +35,7 @@ import com.netflix.hystrix.strategy.properties.HystrixPropertiesStrategy;
|
||||
import com.netflix.hystrix.strategy.properties.HystrixProperty;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.cloud.sleuth.SpanNamer;
|
||||
import org.springframework.cloud.sleuth.instrument.async.TraceCallable;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -25,6 +25,7 @@ import java.util.Map;
|
||||
import brave.propagation.Propagation;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.messaging.support.MessageHeaderAccessor;
|
||||
import org.springframework.messaging.support.NativeMessageHeaderAccessor;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
@@ -121,8 +122,9 @@ enum MessageHeaderPropagation
|
||||
Object nativeHeaders = accessor
|
||||
.getHeader(NativeMessageHeaderAccessor.NATIVE_HEADERS);
|
||||
if (nativeHeaders == null) {
|
||||
nativeHeaders = new LinkedMultiValueMap<>();
|
||||
accessor.setHeader(NativeMessageHeaderAccessor.NATIVE_HEADERS,
|
||||
nativeHeaders = new LinkedMultiValueMap<>());
|
||||
nativeHeaders);
|
||||
}
|
||||
if (nativeHeaders instanceof Map<?, ?>) {
|
||||
((Map) nativeHeaders).put(key, Collections.singletonList(value));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,7 +19,7 @@ package org.springframework.cloud.sleuth.instrument.messaging;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Properties for messaging
|
||||
* Properties for messaging.
|
||||
*
|
||||
* @author Marcin Grzejszczak
|
||||
* @since 2.0.0
|
||||
@@ -48,7 +48,7 @@ public class SleuthMessagingProperties {
|
||||
}
|
||||
|
||||
/**
|
||||
* Properties for Spring Integration
|
||||
* Properties for Spring Integration.
|
||||
*
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
@@ -56,7 +56,7 @@ public class SleuthMessagingProperties {
|
||||
|
||||
/**
|
||||
* An array of patterns against which channel names will be matched.
|
||||
* @see org.springframework.integration.config.GlobalChannelInterceptor#patterns().
|
||||
* @see org.springframework.integration.config.GlobalChannelInterceptor#patterns()
|
||||
* Defaults to any channel name not matching the Hystrix Stream channel name.
|
||||
*/
|
||||
private String[] patterns = new String[] { "!hystrixStreamOutput*", "*" };
|
||||
@@ -145,6 +145,9 @@ public class SleuthMessagingProperties {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* RabbitMQ configuration.
|
||||
*/
|
||||
public static class Rabbit {
|
||||
|
||||
private boolean enabled;
|
||||
@@ -169,6 +172,9 @@ public class SleuthMessagingProperties {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Kafka configuration.
|
||||
*/
|
||||
public static class Kafka {
|
||||
|
||||
private boolean enabled;
|
||||
@@ -193,6 +199,9 @@ public class SleuthMessagingProperties {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* JMS configuration.
|
||||
*/
|
||||
public static class Jms {
|
||||
|
||||
private boolean enabled;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -24,18 +24,36 @@ package org.springframework.cloud.sleuth.instrument.messaging;
|
||||
* @author Marcin Grzejszczak
|
||||
* @since 1.0.4
|
||||
*/
|
||||
public class TraceMessageHeaders {
|
||||
public final class TraceMessageHeaders {
|
||||
|
||||
/**
|
||||
* Span ID message header name.
|
||||
*/
|
||||
public static final String SPAN_ID_NAME = "spanId";
|
||||
|
||||
/**
|
||||
* Span sampled message header name.
|
||||
*/
|
||||
public static final String SAMPLED_NAME = "spanSampled";
|
||||
|
||||
/**
|
||||
* Parent span ID message header name.
|
||||
*/
|
||||
public static final String PARENT_ID_NAME = "spanParentSpanId";
|
||||
|
||||
/**
|
||||
* Trace ID message header name.
|
||||
*/
|
||||
public static final String TRACE_ID_NAME = "spanTraceId";
|
||||
|
||||
/**
|
||||
* Span name message header name.
|
||||
*/
|
||||
public static final String SPAN_NAME_NAME = "spanName";
|
||||
|
||||
/**
|
||||
* Span flags message header name.
|
||||
*/
|
||||
public static final String SPAN_FLAGS_NAME = "spanFlags";
|
||||
|
||||
private TraceMessageHeaders() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -38,6 +38,7 @@ import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
|
||||
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.aop.framework.ProxyFactoryBean;
|
||||
@@ -148,7 +149,7 @@ public class TraceMessagingAutoConfiguration {
|
||||
return new TracingConnectionFactoryBeanPostProcessor(beanFactory);
|
||||
}
|
||||
|
||||
/** Setup the tracing endpoint registry */
|
||||
// Setup the tracing endpoint registry.
|
||||
@Bean
|
||||
JmsListenerConfigurer configureTracing(JmsTracing jmsTracing,
|
||||
CurrentTraceContext current) {
|
||||
@@ -312,8 +313,9 @@ class MessageListenerMethodInterceptor<T extends MessageListener>
|
||||
}
|
||||
catch (RuntimeException | Error e) {
|
||||
String message = e.getMessage();
|
||||
if (message == null)
|
||||
if (message == null) {
|
||||
message = e.getClass().getSimpleName();
|
||||
}
|
||||
span.tag("error", message);
|
||||
throw e;
|
||||
}
|
||||
@@ -322,4 +324,4 @@ class MessageListenerMethodInterceptor<T extends MessageListener>
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,6 +18,7 @@ package org.springframework.cloud.sleuth.instrument.messaging;
|
||||
|
||||
import brave.Tracing;
|
||||
import brave.propagation.Propagation;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,6 +26,7 @@ import brave.propagation.TraceContext;
|
||||
import brave.propagation.TraceContextOrSamplingFlags;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.aop.support.AopUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.sleuth.util.SpanNameUtil;
|
||||
@@ -55,10 +56,18 @@ import org.springframework.util.ClassUtils;
|
||||
* This implementation uses {@link ThreadLocalSpan} to propagate context between
|
||||
* callbacks. This is an alternative to {@code ThreadStatePropagationChannelInterceptor}
|
||||
* which is less sensitive to message manipulation by other interceptors.
|
||||
*
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
public final class TracingChannelInterceptor extends ChannelInterceptorAdapter
|
||||
implements ExecutorChannelInterceptor {
|
||||
|
||||
/**
|
||||
* Name of the class in Spring Cloud Stream that is a direct channel.
|
||||
*/
|
||||
public static final String STREAM_DIRECT_CHANNEL = "org.springframework."
|
||||
+ "cloud.stream.messaging.DirectWithAttributesChannel";
|
||||
|
||||
private static final Log log = LogFactory.getLog(TracingChannelInterceptor.class);
|
||||
|
||||
/**
|
||||
@@ -81,8 +90,6 @@ public final class TracingChannelInterceptor extends ChannelInterceptorAdapter
|
||||
*/
|
||||
private static final String REMOTE_SERVICE_NAME = "broker";
|
||||
|
||||
public static final String STREAM_DIRECT_CHANNEL = "org.springframework.cloud.stream.messaging.DirectWithAttributesChannel";
|
||||
|
||||
final Tracing tracing;
|
||||
|
||||
final Tracer tracer;
|
||||
@@ -134,6 +141,8 @@ public final class TracingChannelInterceptor extends ChannelInterceptorAdapter
|
||||
* <p>
|
||||
* This creates a child from identifiers extracted from the message headers, or a new
|
||||
* span if one couldn't be extracted.
|
||||
* @param message message to use for span creation
|
||||
* @return span to be created
|
||||
*/
|
||||
public Span nextSpan(Message<?> message) {
|
||||
MessageHeaderAccessor headers = mutableHeaderAccessor(message);
|
||||
@@ -329,7 +338,10 @@ public final class TracingChannelInterceptor extends ChannelInterceptorAdapter
|
||||
}
|
||||
|
||||
/**
|
||||
* When an upstream context was not present, lookup keys are unlikely added
|
||||
* When an upstream context was not present, lookup keys are unlikely added.
|
||||
* @param message a message to append tags to
|
||||
* @param result span to customize
|
||||
* @param channel channel to which a message was sent
|
||||
*/
|
||||
void addTags(Message<?> message, SpanCustomizer result, MessageChannel channel) {
|
||||
// TODO topic etc
|
||||
@@ -360,12 +372,14 @@ public final class TracingChannelInterceptor extends ChannelInterceptorAdapter
|
||||
|
||||
void finishSpan(Exception error) {
|
||||
Span span = this.threadLocalSpan.remove();
|
||||
if (span == null || span.isNoop())
|
||||
if (span == null || span.isNoop()) {
|
||||
return;
|
||||
}
|
||||
if (error != null) { // an error occurred, adding error to span
|
||||
String message = error.getMessage();
|
||||
if (message == null)
|
||||
if (message == null) {
|
||||
message = error.getClass().getSimpleName();
|
||||
}
|
||||
span.tag("error", message);
|
||||
}
|
||||
span.finish();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -48,7 +48,7 @@ import org.springframework.jms.listener.endpoint.JmsMessageEndpointManager;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* {@link BeanPostProcessor} wrapping around JMS {@link ConnectionFactory}
|
||||
* {@link BeanPostProcessor} wrapping around JMS {@link ConnectionFactory}.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
* @since 2.1.0
|
||||
@@ -134,14 +134,16 @@ class LazyXAConnectionFactory implements XAConnectionFactory {
|
||||
if (this.jmsTracing != null) {
|
||||
return this.jmsTracing;
|
||||
}
|
||||
return this.jmsTracing = this.beanFactory.getBean(JmsTracing.class);
|
||||
this.jmsTracing = this.beanFactory.getBean(JmsTracing.class);
|
||||
return this.jmsTracing;
|
||||
}
|
||||
|
||||
private XAConnectionFactory wrappedDelegate() {
|
||||
if (this.wrappedDelegate != null) {
|
||||
return this.wrappedDelegate;
|
||||
}
|
||||
return this.wrappedDelegate = jmsTracing().xaConnectionFactory(this.delegate);
|
||||
this.wrappedDelegate = jmsTracing().xaConnectionFactory(this.delegate);
|
||||
return this.wrappedDelegate;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -195,14 +197,16 @@ class LazyConnectionFactory implements ConnectionFactory {
|
||||
if (this.jmsTracing != null) {
|
||||
return this.jmsTracing;
|
||||
}
|
||||
return this.jmsTracing = this.beanFactory.getBean(JmsTracing.class);
|
||||
this.jmsTracing = this.beanFactory.getBean(JmsTracing.class);
|
||||
return this.jmsTracing;
|
||||
}
|
||||
|
||||
private ConnectionFactory wrappedDelegate() {
|
||||
if (this.wrappedDelegate != null) {
|
||||
return this.wrappedDelegate;
|
||||
}
|
||||
return this.wrappedDelegate = jmsTracing().connectionFactory(this.delegate);
|
||||
this.wrappedDelegate = jmsTracing().connectionFactory(this.delegate);
|
||||
return this.wrappedDelegate;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -229,7 +233,8 @@ class LazyMessageListener implements MessageListener {
|
||||
if (this.jmsTracing != null) {
|
||||
return this.jmsTracing;
|
||||
}
|
||||
return this.jmsTracing = this.beanFactory.getBean(JmsTracing.class);
|
||||
this.jmsTracing = this.beanFactory.getBean(JmsTracing.class);
|
||||
return this.jmsTracing;
|
||||
}
|
||||
|
||||
private MessageListener wrappedDelegate() {
|
||||
@@ -242,7 +247,7 @@ class LazyMessageListener implements MessageListener {
|
||||
|
||||
/**
|
||||
* This ensures listeners end up continuing the trace from
|
||||
* {@link MessageConsumer#receive()}
|
||||
* {@link MessageConsumer#receive()}.
|
||||
*/
|
||||
class TracingJmsListenerEndpointRegistry extends JmsListenerEndpointRegistry {
|
||||
|
||||
@@ -295,11 +300,14 @@ class TracingJmsListenerEndpointRegistry extends JmsListenerEndpointRegistry {
|
||||
/**
|
||||
* This wraps the {@link SimpleJmsListenerEndpoint#getMessageListener()} delegate in a
|
||||
* new span.
|
||||
* @param source jms endpoint
|
||||
* @return wrapped endpoint
|
||||
*/
|
||||
SimpleJmsListenerEndpoint trace(SimpleJmsListenerEndpoint source) {
|
||||
MessageListener delegate = source.getMessageListener();
|
||||
if (delegate == null)
|
||||
if (delegate == null) {
|
||||
return source;
|
||||
}
|
||||
source.setMessageListener(this.jmsTracing.messageListener(delegate, false));
|
||||
return source;
|
||||
}
|
||||
@@ -315,6 +323,8 @@ class TracingJmsListenerEndpointRegistry extends JmsListenerEndpointRegistry {
|
||||
* subtype could hold state we aren't aware of, or change behavior. We can consider
|
||||
* checking that input is not a subtype, and most conservatively leaving unknown
|
||||
* subtypes untraced.
|
||||
* @param source jms endpoint
|
||||
* @return wrapped endpoint
|
||||
*/
|
||||
MethodJmsListenerEndpoint trace(MethodJmsListenerEndpoint source) {
|
||||
// Skip out rather than incompletely copying the source
|
||||
@@ -360,7 +370,7 @@ class TracingJmsListenerEndpointRegistry extends JmsListenerEndpointRegistry {
|
||||
}
|
||||
|
||||
/**
|
||||
* This wraps the message listener in a child span
|
||||
* This wraps the message listener in a child span.
|
||||
*/
|
||||
final class TracingMessagingMessageListenerAdapter
|
||||
extends MessagingMessageListenerAdapter {
|
||||
@@ -390,4 +400,4 @@ final class TracingMessagingMessageListenerAdapter
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.cloud.sleuth.instrument.messaging.websocket;
|
||||
|
||||
import brave.Tracing;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
@@ -68,4 +69,4 @@ public class TraceWebSocketAutoConfiguration
|
||||
registration.setInterceptors(TracingChannelInterceptor.create(this.tracing));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,6 +19,7 @@ package org.springframework.cloud.sleuth.instrument.opentracing;
|
||||
import brave.Tracing;
|
||||
import brave.opentracing.BraveTracer;
|
||||
import io.opentracing.Tracer;
|
||||
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -24,15 +24,15 @@ import brave.Tracing;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.reactivestreams.Publisher;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
import reactor.core.CoreSubscriber;
|
||||
import reactor.core.Fuseable;
|
||||
import reactor.core.Scannable;
|
||||
import reactor.core.publisher.Operators;
|
||||
import reactor.util.context.Context;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
/**
|
||||
* Reactive Span pointcuts factories.
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,7 +19,6 @@ package org.springframework.cloud.sleuth.instrument.reactor;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import brave.Span;
|
||||
import brave.Tracer;
|
||||
import brave.Tracing;
|
||||
import brave.propagation.CurrentTraceContext;
|
||||
import brave.propagation.TraceContext;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -25,8 +25,8 @@ import reactor.core.Fuseable;
|
||||
* (implementing {@link reactor.core.Fuseable.QueueSubscription} with default no-op
|
||||
* methods and always negotiating fusion to be {@link Fuseable#NONE}).
|
||||
*
|
||||
* @param <T> - type of the subscription
|
||||
* @author Marcin Grzejszczak
|
||||
* @param <T> - type of the subsciption
|
||||
*/
|
||||
interface SpanSubscription<T>
|
||||
extends Subscription, CoreSubscriber<T>, Fuseable.QueueSubscription<T> {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,9 +23,10 @@ import brave.Tracing;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.reactivestreams.Subscriber;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import reactor.util.context.Context;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
|
||||
/**
|
||||
* Supplier to lazily start a {@link SpanSubscription}.
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -62,11 +62,11 @@ public class TraceReactorAutoConfiguration {
|
||||
@ConditionalOnBean(Tracing.class)
|
||||
static class TraceReactorConfiguration {
|
||||
|
||||
private static final Log log = LogFactory.getLog(TraceReactorConfiguration.class);
|
||||
|
||||
static final String SLEUTH_TRACE_REACTOR_KEY = TraceReactorConfiguration.class
|
||||
.getName();
|
||||
|
||||
private static final Log log = LogFactory.getLog(TraceReactorConfiguration.class);
|
||||
|
||||
@Bean
|
||||
// for tests
|
||||
@ConditionalOnMissingBean
|
||||
@@ -131,4 +131,4 @@ class HookRegisteringBeanDefinitionRegistryPostProcessor
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,6 +20,8 @@ import java.util.Arrays;
|
||||
|
||||
import brave.Tracer;
|
||||
import brave.Tracing;
|
||||
import rx.plugins.RxJavaSchedulersHook;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
@@ -28,7 +30,6 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
|
||||
import org.springframework.cloud.sleuth.autoconfig.TraceAutoConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import rx.plugins.RxJavaSchedulersHook;
|
||||
|
||||
/**
|
||||
* {@link org.springframework.boot.autoconfigure.EnableAutoConfiguration
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -24,6 +24,7 @@ import brave.Tracing;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
|
||||
import org.springframework.cloud.sleuth.util.SpanNameUtil;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,6 +20,7 @@ import java.util.regex.Pattern;
|
||||
|
||||
import brave.Tracer;
|
||||
import brave.Tracing;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,6 +21,7 @@ import java.net.URI;
|
||||
import brave.SpanCustomizer;
|
||||
import brave.http.HttpAdapter;
|
||||
import brave.http.HttpClientParser;
|
||||
|
||||
import org.springframework.cloud.sleuth.util.SpanNameUtil;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -84,4 +84,4 @@ class SleuthHttpServerParser extends HttpServerParser {
|
||||
error(httpStatus, error, customizer);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,7 +31,8 @@ public class SleuthWebProperties {
|
||||
/**
|
||||
* Default set of skip patterns.
|
||||
*/
|
||||
public static final String DEFAULT_SKIP_PATTERN = "/api-docs.*|/swagger.*|.*\\.png|.*\\.css|.*\\.js|.*\\.html|/favicon.ico|/hystrix.stream";
|
||||
public static final String DEFAULT_SKIP_PATTERN = "/api-docs.*|/swagger.*|"
|
||||
+ ".*\\.png|.*\\.css|.*\\.js|.*\\.html|/favicon.ico|/hystrix.stream";
|
||||
|
||||
/**
|
||||
* When true enables instrumentation for web applications.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,6 +23,7 @@ import brave.http.HttpClientParser;
|
||||
import brave.http.HttpSampler;
|
||||
import brave.http.HttpServerParser;
|
||||
import brave.http.HttpTracing;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,6 +23,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import brave.spring.webmvc.SpanCustomizingAsyncHandlerInterceptor;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,6 +26,7 @@ import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
|
||||
import org.springframework.cloud.sleuth.SpanNamer;
|
||||
import org.springframework.cloud.sleuth.instrument.async.TraceCallable;
|
||||
import org.springframework.web.context.request.async.WebAsyncTask;
|
||||
@@ -74,7 +75,7 @@ public class TraceWebAspect {
|
||||
|
||||
@Pointcut("@within(org.springframework.web.bind.annotation.RestController)")
|
||||
private void anyRestControllerAnnotated() {
|
||||
}// NOSONAR
|
||||
} // NOSONAR
|
||||
|
||||
@Pointcut("@within(org.springframework.stereotype.Controller)")
|
||||
private void anyControllerAnnotated() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.sleuth.instrument.web;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -23,6 +24,7 @@ import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import brave.Tracing;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
|
||||
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties;
|
||||
@@ -74,9 +76,10 @@ public class TraceWebAutoConfiguration {
|
||||
protected static class ManagementSkipPatternProviderConfig {
|
||||
|
||||
/**
|
||||
* Sets or appends
|
||||
* {@link ManagementServerProperties#getServlet()#getContextPath()} to the skip
|
||||
* Sets or appends {@link ManagementServerProperties#getServlet()} to the skip
|
||||
* pattern. If neither is available then sets the default one
|
||||
* @param managementServerProperties properties
|
||||
* @return optional skip pattern
|
||||
*/
|
||||
static Optional<Pattern> getPatternForManagementServerProperties(
|
||||
ManagementServerProperties managementServerProperties) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -147,6 +147,11 @@ public final class TraceWebFilter implements WebFilter, Ordered {
|
||||
return new MonoWebFilterTrace(chain.filter(exchange), exchange, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return sleuthWebProperties().getFilterOrder();
|
||||
}
|
||||
|
||||
private static class MonoWebFilterTrace extends MonoOperator<Void, Void> {
|
||||
|
||||
final ServerWebExchange exchange;
|
||||
@@ -176,6 +181,37 @@ public final class TraceWebFilter implements WebFilter, Ordered {
|
||||
findOrCreateSpan(context), this));
|
||||
}
|
||||
|
||||
private Span findOrCreateSpan(Context c) {
|
||||
Span span;
|
||||
if (c.hasKey(Span.class)) {
|
||||
Span parent = c.get(Span.class);
|
||||
span = this.tracer
|
||||
.nextSpan(TraceContextOrSamplingFlags.create(parent.context()))
|
||||
.start();
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Found span in reactor context" + span);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (this.attrSpan != null) {
|
||||
span = this.attrSpan;
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Found span in attribute " + span);
|
||||
}
|
||||
}
|
||||
else {
|
||||
span = this.handler.handleReceive(this.extractor,
|
||||
this.exchange.getRequest().getHeaders(),
|
||||
this.exchange.getRequest());
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Handled receive of span " + span);
|
||||
}
|
||||
}
|
||||
this.exchange.getAttributes().put(TRACE_REQUEST_ATTR, span);
|
||||
}
|
||||
return span;
|
||||
}
|
||||
|
||||
static final class WebFilterTraceSubscriber implements CoreSubscriber<Void> {
|
||||
|
||||
final CoreSubscriber<? super Void> actual;
|
||||
@@ -288,47 +324,13 @@ public final class TraceWebFilter implements WebFilter, Ordered {
|
||||
|
||||
}
|
||||
|
||||
private Span findOrCreateSpan(Context c) {
|
||||
Span span;
|
||||
if (c.hasKey(Span.class)) {
|
||||
Span parent = c.get(Span.class);
|
||||
span = this.tracer
|
||||
.nextSpan(TraceContextOrSamplingFlags.create(parent.context()))
|
||||
.start();
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Found span in reactor context" + span);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (this.attrSpan != null) {
|
||||
span = this.attrSpan;
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Found span in attribute " + span);
|
||||
}
|
||||
}
|
||||
else {
|
||||
span = this.handler.handleReceive(this.extractor,
|
||||
this.exchange.getRequest().getHeaders(),
|
||||
this.exchange.getRequest());
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Handled receive of span " + span);
|
||||
}
|
||||
}
|
||||
this.exchange.getAttributes().put(TRACE_REQUEST_ATTR, span);
|
||||
}
|
||||
return span;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return sleuthWebProperties().getFilterOrder();
|
||||
}
|
||||
|
||||
static final class DecoratedServerHttpResponse extends ServerHttpResponseDecorator {
|
||||
|
||||
final String method, httpRoute;
|
||||
final String method;
|
||||
|
||||
final String httpRoute;
|
||||
|
||||
DecoratedServerHttpResponse(ServerHttpResponse delegate, String method,
|
||||
String httpRoute) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,9 +13,11 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.sleuth.instrument.web;
|
||||
|
||||
import brave.Tracing;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.cloud.sleuth.instrument.web;
|
||||
|
||||
import brave.spring.webmvc.SpanCustomizingAsyncHandlerInterceptor;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -25,7 +26,7 @@ import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
/**
|
||||
* MVC Adapter that adds the {@link SpanCustomizingAsyncHandlerInterceptor}
|
||||
* MVC Adapter that adds the {@link SpanCustomizingAsyncHandlerInterceptor}.
|
||||
*
|
||||
* @author Marcin Grzejszczak
|
||||
* @since 1.0.3
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,6 +22,7 @@ import brave.Tracing;
|
||||
import brave.http.HttpTracing;
|
||||
import brave.servlet.TracingFilter;
|
||||
import brave.spring.webmvc.SpanCustomizingAsyncHandlerInterceptor;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.sleuth.instrument.web.client;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
@@ -118,6 +119,10 @@ class HttpClientBeanPostProcessor implements BeanPostProcessor {
|
||||
this.beanFactory = beanFactory;
|
||||
}
|
||||
|
||||
static TracingDoOnRequest create(BeanFactory beanFactory) {
|
||||
return new TracingDoOnRequest(beanFactory);
|
||||
}
|
||||
|
||||
private HttpTracing httpTracing() {
|
||||
if (this.httpTracing == null) {
|
||||
this.httpTracing = this.beanFactory.getBean(HttpTracing.class);
|
||||
@@ -146,10 +151,6 @@ class HttpClientBeanPostProcessor implements BeanPostProcessor {
|
||||
return this.handler;
|
||||
}
|
||||
|
||||
static TracingDoOnRequest create(BeanFactory beanFactory) {
|
||||
return new TracingDoOnRequest(beanFactory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(HttpClientRequest req, Connection connection) {
|
||||
if (propagation().keys().stream()
|
||||
@@ -285,4 +286,4 @@ class HttpClientBeanPostProcessor implements BeanPostProcessor {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.sleuth.instrument.web.client;
|
||||
|
||||
import brave.Span;
|
||||
@@ -30,18 +31,18 @@ import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
|
||||
class TraceRequestHttpHeadersFilter extends AbstractHttpHeadersFilter {
|
||||
final class TraceRequestHttpHeadersFilter extends AbstractHttpHeadersFilter {
|
||||
|
||||
private static final Log log = LogFactory.getLog(TraceRequestHttpHeadersFilter.class);
|
||||
|
||||
static HttpHeadersFilter create(HttpTracing httpTracing) {
|
||||
return new TraceRequestHttpHeadersFilter(httpTracing);
|
||||
}
|
||||
|
||||
private TraceRequestHttpHeadersFilter(HttpTracing httpTracing) {
|
||||
super(httpTracing);
|
||||
}
|
||||
|
||||
static HttpHeadersFilter create(HttpTracing httpTracing) {
|
||||
return new TraceRequestHttpHeadersFilter(httpTracing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpHeaders filter(HttpHeaders input, ServerWebExchange exchange) {
|
||||
if (log.isDebugEnabled()) {
|
||||
@@ -68,19 +69,19 @@ class TraceRequestHttpHeadersFilter extends AbstractHttpHeadersFilter {
|
||||
|
||||
}
|
||||
|
||||
class TraceResponseHttpHeadersFilter extends AbstractHttpHeadersFilter {
|
||||
final class TraceResponseHttpHeadersFilter extends AbstractHttpHeadersFilter {
|
||||
|
||||
private static final Log log = LogFactory
|
||||
.getLog(TraceResponseHttpHeadersFilter.class);
|
||||
|
||||
static HttpHeadersFilter create(HttpTracing httpTracing) {
|
||||
return new TraceResponseHttpHeadersFilter(httpTracing);
|
||||
}
|
||||
|
||||
private TraceResponseHttpHeadersFilter(HttpTracing httpTracing) {
|
||||
super(httpTracing);
|
||||
}
|
||||
|
||||
static HttpHeadersFilter create(HttpTracing httpTracing) {
|
||||
return new TraceResponseHttpHeadersFilter(httpTracing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpHeaders filter(HttpHeaders input, ServerWebExchange exchange) {
|
||||
Object storedSpan = exchange.getAttribute(SPAN_ATTRIBUTE);
|
||||
@@ -162,4 +163,4 @@ abstract class AbstractHttpHeadersFilter implements HttpHeadersFilter {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -24,6 +24,7 @@ import javax.annotation.PostConstruct;
|
||||
|
||||
import brave.http.HttpTracing;
|
||||
import brave.spring.web.TracingAsyncClientHttpRequestInterceptor;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
@@ -39,7 +40,7 @@ import org.springframework.web.client.AsyncRestTemplate;
|
||||
/**
|
||||
* {@link org.springframework.boot.autoconfigure.EnableAutoConfiguration
|
||||
* Auto-configuration} enables span information propagation for
|
||||
* {@link AsyncClientHttpRequestFactory} and {@link AsyncRestTemplate}
|
||||
* {@link AsyncClientHttpRequestFactory} and {@link AsyncRestTemplate}.
|
||||
*
|
||||
* @author Marcin Grzejszczak
|
||||
* @since 1.0.0
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user