If the flag is set then annotations are collected and the data are exported
in zipkin or stream. If not you still get the correlation ids, so a purely
log-oriented solution will always have useful data on all requests.
Instrumentation should be able to get by with only 2
interfaces: TraceManager and TraceAccessor (the former is
not needed if you aren't starting a new Span). No explicit
access to thread locals or manipulation of thread context
is required (except locally where necessary).
A Span is enclosed by a Trace (actually a view of the complete
Trace that would be constructed remotely).
Zipkin now has Span.timestamp/duration, so no more need for
"aquire/release".
This also corrects the host/endpoint logged for timeline annotations, as
it should always be the local process.
KV annotations are just "annotations", and the "start" and "stop"
annotations in zipkin are "acquire" and "release" (since, in
particular the latter can in principle happen more than once
and not necessarily the last thing that happens to a span).
TODO: decide if TraceContextHolder is really holding a Span
or a TraceContext (or TraceScope). Maybe think of a better
name for TraceScope.
There was an ordering error in the conditions as well, causing the
wrong async customizers to be registered. Another issue was the
servlet async processing (request atribute not cached in all branches)
resulting in multiple spans per request.
An @Async method should start a new trace. Still not finished that bit
because if the user also customizes the async post processor there will
be a clash.
Biggest change here is better support for async web requests.
Each async request goes through the TraceFilter multiple times so you
have to re-attach to the span in the request if there is one.
Directly using the collector gives us more control of the annotations.
The main improvement/change here is that we need to send the span
name and parent details downstream as well as the span id. It's not
logically required by the trace model, but zipkin needs it, so it
can set annotations on the parent span (server recv/send).