From 9417110e905d029b2c80ec629c3a9f466f63e83c Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Sat, 23 Jan 2016 17:28:12 +0100 Subject: [PATCH] Changes http key delimiter to dot and adds size keys --- .../cloud/sleuth/instrument/TraceKeys.java | 28 ++++++++++++++----- .../instrument/web/TraceFilterTests.java | 14 +++++----- .../stream/ZipkinMessageListenerTests.java | 4 +-- .../zipkin/ZipkinSpanListenerTests.java | 4 +-- 4 files changed, 32 insertions(+), 18 deletions(-) diff --git a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/TraceKeys.java b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/TraceKeys.java index d4c89caa1..0333136fc 100644 --- a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/TraceKeys.java +++ b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/TraceKeys.java @@ -94,13 +94,13 @@ public class TraceKeys { * The domain portion of the URL or host header. Example: * "mybucket.s3.amazonaws.com". Used to filter by host as opposed to ip address. */ - private String host = "http/host"; + private String host = "http.host"; /** * The HTTP method, or verb, such as "GET" or "POST". Used to filter against an * http route. */ - private String method = "http/method"; + private String method = "http.method"; /** * The absolute http path, without any query parameters. Example: @@ -115,29 +115,43 @@ public class TraceKeys { * "/resource/abcd-ff". Historical note: This was commonly expressed as "http.uri" * in zipkin, eventhough it was most often just a path. */ - private String path = "http/path"; + private String path = "http.path"; /** * The entire URL, including the scheme, host and query parameters if available. * Ex. * "https://mybucket.s3.amazonaws.com/objects/abcd-ff?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Algorithm=AWS4-HMAC-SHA256..." - * Combined with {@link #HTTP_METHOD}, you can understand the fully-qualified + * Combined with {@link #method}, you can understand the fully-qualified * request line. This is optional as it may include private data or be of * considerable length. */ - private String url = "http/url"; + private String url = "http.url"; /** * The HTTP response code, when not in 2xx range. Ex. "503" Used to filter for * error status. 2xx range are not logged as success codes are less interesting * for latency troubleshooting. Omitting saves at least 20 bytes per span. */ - private String statusCode = "http/status_code"; + private String statusCode = "http.status_code"; + + /** + * The size of the non-empty HTTP request body, in bytes. Ex. "16384" + * + *

Large uploads can exceed limits or contribute directly to latency. + */ + private String requestSize = "http.request.size"; + + /** + * The size of the non-empty HTTP response body, in bytes. Ex. "16384" + * + *

Large downloads can exceed limits or contribute directly to latency. + */ + private String responseSize = "http.response.size"; /** * Prefix for header names if they are added as tags. */ - private String prefix = "http/"; + private String prefix = "http."; /** * Additional headers that should be added as tags if they exist. If the header diff --git a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/TraceFilterTests.java b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/TraceFilterTests.java index 194244c63..9346e4ecd 100644 --- a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/TraceFilterTests.java +++ b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/TraceFilterTests.java @@ -147,7 +147,7 @@ public class TraceFilterTests { this.request.addHeader("X-Foo", "bar"); filter.doFilter(this.request, this.response, this.filterChain); - assertThat(this.span.tags()).contains(entry("http/x-foo", "bar")); + assertThat(this.span.tags()).contains(entry("http.x-foo", "bar")); assertNull(SpanContextHolder.getCurrentSpan()); } @@ -163,7 +163,7 @@ public class TraceFilterTests { this.request.addHeader("X-Foo", "spam"); filter.doFilter(this.request, this.response, this.filterChain); - assertThat(this.span.tags()).contains(entry("http/x-foo", "'bar','spam'")); + assertThat(this.span.tags()).contains(entry("http.x-foo", "'bar','spam'")); assertNull(SpanContextHolder.getCurrentSpan()); } @@ -199,17 +199,17 @@ public class TraceFilterTests { * org.springframework.cloud.sleuth.instrument.TraceKeys}. */ public void verifyHttpTags(HttpStatus status) { - assertThat(this.span.tags()).contains(entry("http/host", "localhost"), - entry("http/url", "http://localhost/?foo=bar"), entry("http/path", "/"), - entry("http/method", "GET")); + assertThat(this.span.tags()).contains(entry("http.host", "localhost"), + entry("http.url", "http://localhost/?foo=bar"), entry("http.path", "/"), + entry("http.method", "GET")); // Status is only interesting in non-success case. Omitting it saves at least // 20bytes per span. if (status.is2xxSuccessful()) { - assertThat(this.span.tags()).doesNotContainKey("http/status_code"); + assertThat(this.span.tags()).doesNotContainKey("http.status_code"); } else { - assertThat(this.span.tags()).containsEntry("http/status_code", + assertThat(this.span.tags()).containsEntry("http.status_code", status.toString()); } } diff --git a/spring-cloud-sleuth-zipkin-stream/src/test/java/org/springframework/cloud/sleuth/zipkin/stream/ZipkinMessageListenerTests.java b/spring-cloud-sleuth-zipkin-stream/src/test/java/org/springframework/cloud/sleuth/zipkin/stream/ZipkinMessageListenerTests.java index 2871b8906..08bc047ee 100644 --- a/spring-cloud-sleuth-zipkin-stream/src/test/java/org/springframework/cloud/sleuth/zipkin/stream/ZipkinMessageListenerTests.java +++ b/spring-cloud-sleuth-zipkin-stream/src/test/java/org/springframework/cloud/sleuth/zipkin/stream/ZipkinMessageListenerTests.java @@ -36,7 +36,7 @@ public class ZipkinMessageListenerTests { @Test public void convertsTimestampAndDurationToMicroseconds() { long start = System.currentTimeMillis(); - this.span.log("http/request/retry"); // System.currentTimeMillis + this.span.log("hystrix/retry"); // System.currentTimeMillis zipkin.Span result = ZipkinMessageListener.convert(this.span, this.host); @@ -52,7 +52,7 @@ public class ZipkinMessageListenerTests { /** Sleuth host corresponds to annotation/binaryAnnotation.host in zipkin. */ @Test public void annotationsIncludeHost() { - this.span.log("http/request/retry"); + this.span.log("hystrix/retry"); this.span.tag("spring-boot/version", "1.3.1.RELEASE"); zipkin.Span result = ZipkinMessageListener.convert(this.span, this.host); diff --git a/spring-cloud-sleuth-zipkin/src/test/java/org/springframework/cloud/sleuth/zipkin/ZipkinSpanListenerTests.java b/spring-cloud-sleuth-zipkin/src/test/java/org/springframework/cloud/sleuth/zipkin/ZipkinSpanListenerTests.java index 36074e60a..c299c7211 100644 --- a/spring-cloud-sleuth-zipkin/src/test/java/org/springframework/cloud/sleuth/zipkin/ZipkinSpanListenerTests.java +++ b/spring-cloud-sleuth-zipkin/src/test/java/org/springframework/cloud/sleuth/zipkin/ZipkinSpanListenerTests.java @@ -75,7 +75,7 @@ public class ZipkinSpanListenerTests { @Test public void convertsTimestampAndDurationToMicroseconds() { long start = System.currentTimeMillis(); - this.parent.log("http/request/retry"); // System.currentTimeMillis + this.parent.log("hystrix/retry"); // System.currentTimeMillis zipkin.Span result = this.listener.convert(this.parent); @@ -91,7 +91,7 @@ public class ZipkinSpanListenerTests { /** Sleuth host corresponds to annotation/binaryAnnotation.host in zipkin. */ @Test public void annotationsIncludeHost() { - this.parent.log("http/request/retry"); + this.parent.log("hystrix/retry"); this.parent.tag("spring-boot/version", "1.3.1.RELEASE"); zipkin.Span result = this.listener.convert(this.parent);