Merge branch 'master' into 2.0.x

This commit is contained in:
Marcin Grzejszczak
2017-10-16 08:10:54 +02:00
3 changed files with 22 additions and 2 deletions

View File

@@ -66,7 +66,9 @@ abstract class AbstractTraceHttpRequestInterceptor {
}
private String getName(URI uri) {
return SpanNameUtil.shorten(uriScheme(uri) + ":" + uri.getPath());
// The returned name should comply with RFC 882 - Section 3.1.2.
// i.e Header values must composed of printable ASCII values.
return SpanNameUtil.shorten(uriScheme(uri) + ":" + uri.getRawPath());
}
private String uriScheme(URI uri) {

View File

@@ -22,6 +22,7 @@ import java.util.List;
import java.util.Map;
import java.util.Random;
import org.apache.commons.lang.StringUtils;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@@ -156,6 +157,23 @@ public class TraceRestTemplateInterceptorTests {
then(this.testController.span).hasNameEqualTo("http:/");
}
@Test
public void createdSpanNameHasOnlyPrintableAsciiCharactersForNonEncodedURIWithNonAsciiChars() {
this.tracer.continueSpan(Span.builder().traceId(1L).spanId(2L).exportable(false).build());
try {
this.template.getForEntity("/cas~fs~划", Map.class).getBody();
}
catch (Exception e) {
}
String spanName = this.spanAccumulator.getSpans().get(0).getName();
then(this.spanAccumulator.getSpans().get(0).getName()).isEqualTo("http:/cas~fs~%C3%A5%CB%86%E2%80%99");
then(StringUtils.isAsciiPrintable(spanName));
then(ExceptionUtils.getLastException()).isNull();
}
@Test
public void willShortenTheNameOfTheSpan() {
this.tracer.continueSpan(Span.builder().traceId(1L).spanId(2L).exportable(false).build());

View File

@@ -107,7 +107,7 @@
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.6.0</version>
<version>3.9.0</version>
<scope>test</scope>
</dependency>
<dependency>