Re-added missing server side span (#322)

* Re-added missing server side span

with this change

- HandlerInterceptor is responsible for wrapping requests in spans
- added Sring Data REST instrumentation
- added Zuul instrumentation
- it will not wrap error controller related requests with spans
- tests have been changed to ensure that ALWAYS there is at least one span on the server side (that way it will show up in Zipkin)
- "fallback" mechanism has been added that if a HandlerInterceptor hasn't been used then we are forcing creation of a Span at the server side

fixes #321
(cherry picked from commit 4f1ef52e6c)
This commit is contained in:
Marcin Grzejszczak
2016-07-07 10:56:07 +02:00
parent 9d296a47b6
commit bfce279d52
34 changed files with 1140 additions and 108 deletions

View File

@@ -145,7 +145,7 @@ be low cardinality (e.g. not include identifiers).
Since there is a lot of instrumentation going on some of the span names will be
artificial like:
- `http:path` when received an http request on a given path
- `controller-method-name` when received by a Controller with a method name `conrollerMethodName`
- `async` for asynchronous operations done via wrapped `Callable` and `Runnable`.
- `@Scheduled` annotated methods will return the simple name of the class.
@@ -428,6 +428,15 @@ Via the `TraceFilter` all sampled incoming requests result in creation of a Span
like to skip via the `spring.sleuth.web.skipPattern` property. If you have `ManagementServerProperties` on classpath then
its value of `contextPath` gets appended to the provided skip pattern.
==== HandlerInterceptor
Since we want the span names to be precise we're using a `TraceHandlerInterceptor` that either wraps an
existing `HandlerInterceptor` or is added directly to the list of existing `HandlerInterceptors`. The
`TraceHandlerInterceptor` adds a special request attribute to the given `HttpServletRequest`. If the
the `TraceFilter` doesn't see this attribute set it will create a "fallback" span which is an additional
span created on the server side so that the trace is presented properly in the UI. Seeing that most likely
signifies that there is a missing instrumentation. In that case please file an issue in Spring Cloud Sleuth.
==== Async Servlet support
If your controller returns a `Callable` or a `WebAsyncTask` Spring Cloud Sleuth will continue the existing span instead of creating a new one.