Add request path to span name

This commit is contained in:
Dave Syer
2015-07-28 17:56:48 +01:00
parent 97ae6151e2
commit 203e97681d
3 changed files with 29 additions and 4 deletions

View File

@@ -10,10 +10,10 @@ include::intro.adoc[]
== Running the sample
1. Run [Zipkin](https://github.com/openzipkin/zipkin), e.g. via the docker images at [Zipkin Docker](https://github.com/openzipkin/zipkin-docker)
1. Run [Zipkin](https://github.com/openzipkin/zipkin), e.g. via docker compose (there's a `docker-compose.yml` in [Spring Cloud Sleuth](https://github.com/spring-cloud-incubator/spring-cloud-sleuth), or in [Docker Zipkin](https://github.com/openzipkin/docker-zipkin)
7. Run sample application
8. Hit `http://localhost:3380`
9. Goto `http://localhost:8080` for zipkin web
9. Goto `http://localhost:8082` for zipkin web
== Building

View File

@@ -33,6 +33,7 @@ import org.springframework.cloud.sleuth.TraceScope;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.web.filter.OncePerRequestFilter;
import org.springframework.web.util.UrlPathHelper;
/**
* Filter that takes the value of the {@link Trace#SPAN_ID_NAME} and
@@ -54,6 +55,7 @@ public class TraceFilter extends OncePerRequestFilter {
private final Trace trace;
private final Pattern skipPattern;
private UrlPathHelper urlPathHelper = new UrlPathHelper();
public TraceFilter(Trace trace) {
this.trace = trace;
@@ -77,17 +79,18 @@ public class TraceFilter extends OncePerRequestFilter {
if (!skip) {
String spanId = getHeader(request, response, SPAN_ID_NAME);
String traceId = getHeader(request, response, TRACE_ID_NAME);
String name = "traceFilter" + this.urlPathHelper.getPathWithinApplication(request);
if (hasText(spanId) && hasText(traceId)) {
TraceInfo traceInfo = new TraceInfo(traceId, spanId);
// TODO: trace description?
traceScope = this.trace.startSpan("traceFilter", traceInfo);
traceScope = this.trace.startSpan(name, traceInfo);
// Send new span id back
addToResponseIfNotPresent(response, SPAN_ID_NAME, traceScope.getSpan()
.getSpanId());
}
else {
traceScope = this.trace.startSpan("traceFilter");
traceScope = this.trace.startSpan(name);
}
}

View File

@@ -0,0 +1,22 @@
cassandra:
image: itszero/zipkin-cassandra
collector:
image: itszero/zipkin-collector
expose:
- 9410
ports:
- 9410:9410
links:
- cassandra:db
query:
image: itszero/zipkin-query
expose:
- 9411
links:
- cassandra:db
web:
image: itszero/zipkin-web
links:
- query
ports:
- 8082:8080