There was emmense work to prepare for decoupling of spring-cloud-sleuth-core
from Zipkin. This included complete test conversion and deprecations between
2.2.x and 3.0.x.
This moves all Zipkin related code to spring-cloud-sleuth-zipkin, making the
primary data recording tool `SpanHandler` as opposed to `Reporter<zipkin2.Span>`
For example, Wavefront and soon Stackdriver can implement `SpanHandler` and
skip conversion into the Zipkin model first. `SpanHandler` also includes
begin and end hooks which allow data extensions to be developed.
see https://github.com/wavefrontHQ/wavefront-spring-boot
This is more prevention of a problem, then seeing one in practice.
Technically, a TracingCustomizer can order things backwards, and it hit
me in a test env (not sleuth).
This allows integrations of Sleuth to use the same approach for 2.2.x as 3.x:
If you have a custom base propagation format, override the `BaggagePropagation.Factory`
bean instead of `ExtraFieldsPropagation.Factory`
Note: one subtle difference 2.2.x to 3.x is the change in the primary inject format.
2.2.x is
```java
return BaggagePropagation.newFactoryBuilder(B3Propagation.newFactoryBuilder()
.injectFormat(B3Propagation.Format.MULTI).build());
```
3.0 is
```java
return BaggagePropagation.newFactoryBuilder(B3Propagation.newFactoryBuilder()
.injectFormat(B3Propagation.Format.SINGLE_NO_PARENT).build());
```
per #1607
See https://github.com/spring-cloud/spring-cloud-gcp/issues/2268
Brave's SpanHandler can report natively in other formats which have different
constraints than Zipkin and often extensions to the data model.
This change ports all tests away from Zipkin's types so that it is more clear
what's actually recorded vs what's a side-effect of Zipkin conversion.
This removes `BlockingQueueSpanReporter` which was never released, also.
I had flakes on TraceAsyncIntegrationTests and it was hard to tell why
as there were so many problems with it. It used a normal list in async
setting, it unnecessarily created extra spans, it added a hook inside
the async method which if passed only told you it was in the middle of
an op, not the end of it. The method danced around making failure in
console almost impossible to decipher.
This took me a few hours to make just a normal test. Hopefully, the
others will keep passing as I can't afford time to redo all of them.
This puts specific comments in as to why certain files that seem like they
shouldn't be public are. Notably, this includes entrypoint autoconfiguration,
which are sometimes order sensitive. In other cases there are types that were
documented (notably the async package).
This also untangles a few configuration.
I noticed we deleted many things without deprecation in 3.x and figured
deprecation was the right way. However, this doesn't work for auto-config
properties. This replaces deprecation with a TODO note to hide all the
types so that 4.x won't require guessing if someone externally is using
them directly or not.
`SpanHandler` is the base type for the now deprecated `FinishedSpanHandler`.
Notable, it can not just handle things at the end of a recording, but also the
beginning.
For example, this permits set-once baggage without the HTTP abstraction:
```java
static final BaggageField EPOCH_SECONDS = BaggageField.create("epoch_seconds");
static final class RootOnlyBaggage extends SpanHandler {
@Override
public boolean begin(TraceContext context, MutableSpan span, @Nullable TraceContext parent) {
if (EPOCH_SECONDS.getValue(context) == null) { // only set at the first span
long epochSeconds = System.currentTimeMillis() / 1000;
EPOCH_SECONDS.updateValue(context, String.valueOf(epochSeconds));
}
return true;
}
@Override public boolean end(TraceContext context, MutableSpan span, Cause cause) {
Tags.BAGGAGE_FIELD.tag(EPOCH_SECONDS, context, span);
return true;
}
}
```
As the parent is available, it can also facilitate advanced tasks like counting
children, or summarizing entire local roots.
See https://github.com/openzipkin/brave/tree/master/brave/src/test/java/brave/features/handler
and https://github.com/openzipkin/brave/blob/master/brave/src/main/java/brave/handler/SpanHandler.java for more
Types like Properties and AutoConfiguration and internal utilities are
routinely marked public when they needn't be. This causes toil as we
have to preserve signatures even if they were made public by accident.
This deprecates the mass of types marked public to give some hope of
less undifferentiated toil in the future. Ideally, future change will
consider greatly if a type should be public or not as doing so haunts
maintainers.