Updated the stream header setting in env post processor
without this kafka needs to add headers manually in properties with this change is not necessary fixes #529
This commit is contained in:
@@ -25,7 +25,7 @@ import java.util.Properties;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.env.EnvironmentPostProcessor;
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.instrument.messaging.TraceMessageHeaders;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.core.env.MapPropertySource;
|
||||
import org.springframework.core.env.MutablePropertySources;
|
||||
@@ -46,9 +46,9 @@ import org.springframework.core.io.support.PropertiesLoaderUtils;
|
||||
public class StreamEnvironmentPostProcessor implements EnvironmentPostProcessor {
|
||||
|
||||
private static final String PROPERTY_SOURCE_NAME = "defaultProperties";
|
||||
static String[] headers = new String[] { Span.SPAN_ID_NAME,
|
||||
Span.TRACE_ID_NAME, Span.PARENT_ID_NAME, Span.PROCESS_ID_NAME,
|
||||
Span.SAMPLED_NAME, Span.SPAN_NAME_NAME };
|
||||
static String[] headers = new String[] { TraceMessageHeaders.SPAN_ID_NAME,
|
||||
TraceMessageHeaders.TRACE_ID_NAME, TraceMessageHeaders.PARENT_ID_NAME, TraceMessageHeaders.PROCESS_ID_NAME,
|
||||
TraceMessageHeaders.SAMPLED_NAME, TraceMessageHeaders.SPAN_NAME_NAME };
|
||||
|
||||
@Override
|
||||
public void postProcessEnvironment(ConfigurableEnvironment environment,
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.springframework.cloud.sleuth.stream;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -25,10 +23,12 @@ import java.util.stream.Collectors;
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.instrument.messaging.TraceMessageHeaders;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.core.env.StandardEnvironment;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
@@ -43,7 +43,7 @@ public class StreamEnvironmentPostProcessorTests {
|
||||
postProcess();
|
||||
assertThat(this.environment
|
||||
.getProperty("spring.cloud.stream.test.binder.headers[0]"))
|
||||
.isEqualTo(Span.SPAN_ID_NAME);
|
||||
.isEqualTo(TraceMessageHeaders.SPAN_ID_NAME);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -54,7 +54,7 @@ public class StreamEnvironmentPostProcessorTests {
|
||||
postProcess();
|
||||
assertThat(this.environment
|
||||
.getProperty("spring.cloud.stream.test.binder.headers[2]"))
|
||||
.isEqualTo(Span.SPAN_ID_NAME);
|
||||
.isEqualTo(TraceMessageHeaders.SPAN_ID_NAME);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -66,7 +66,7 @@ public class StreamEnvironmentPostProcessorTests {
|
||||
Collection<String> headerValues = defaultPropertiesSource().values();
|
||||
|
||||
Collection<String> traceIds = headerValues.stream()
|
||||
.filter(input -> input.contains(Span.TRACE_ID_NAME))
|
||||
.filter(input -> input.contains(TraceMessageHeaders.TRACE_ID_NAME))
|
||||
.collect(Collectors.toList());
|
||||
assertThat(traceIds).hasSize(1);
|
||||
assertThat(defaultPropertiesSource().keySet().stream()
|
||||
|
||||
Reference in New Issue
Block a user