281 Commits

Author SHA1 Message Date
Marcin Grzejszczak
28d8802f4a Merge branch '2.2.x' 2021-03-29 15:00:54 +02:00
Maziz
10ff66372e Implement mechanism to apply custom api path (#1859)
* Implement mechanism to apply custom api path to the sleuth server baseUrl.
This comes in handy when another monitoring tool is being used, for instance new relic, which doesn't not require path in its tracing api.

* Fix up documentation on the ZipkinProperties

* Update the main documentation for api path

* Add missing comma
2021-02-27 10:16:46 +01:00
Marcin Grzejszczak
899410a2b0 Updated copyrights 2021-02-25 15:24:10 +01:00
Marcin Grzejszczak
de33b91739 Upgraded copyrights 2021-02-25 12:43:46 +01:00
Marcin Grzejszczak
76ad931b42 Refactoring modules to be consistent with Spring Boot (#1784)
# Modules

* New modules: `spring-cloud-sleuth-autoconfigure`, `spring-cloud-sleuth-api`, `spring-cloud-sleuth-instrumentation`
  `spring-cloud-sleuth-core` removed and changed to `spring-cloud-sleuth-instrumentation` & `spring-cloud-sleuth-api`
* Removed `spring-cloud-starter-sleuth-otel`
  To add OpenTelemetry support you need to add `spring-cloud-starter-sleuth` (adds Brave by default), exclude Brave and add `spring-cloud-sleuth-otel` dependency
* Except for the tests, `spring-cloud-sleuth-autoconfigure` is the only module that can have access to `@Configuration`, `@ConfigurationProperties` classes.
Tests have been added to ensure such separation.

## Package moving

* `org.springframework.cloud.sleuth.api` -> `org.springframework.cloud.sleuth`
* `org.springframework.cloud.sleuth.brave.autoconfig` -> `org.springframework.cloud.sleuth.autoconfig.brave`
* `org.springframework.cloud.sleuth.otel.autoconfig` -> `org.springframework.cloud.sleuth.autoconfig.otel`
* `org.springframework.cloud.sleuth` -> `org.springframework.cloud.sleuth`
* Instrumentation: `org.springframework.cloud.sleuth.annotation` -> `org.springframework.cloud.sleuth.instrument.annotation`
* All the autoconfiguration classes were moved under `org.springframework.cloud/sleuth.autoconfig` package

## Global class modifications

* Any class registered as a bean is now public

## Classes

* `RateLimitingSampler` constructor changed
* Merged a lot of auto configuration classes into one (e.g. `BraveAutoConfiguration` now imports various other configurations)
* Renamed `TraceBraveAutoConfiguration` to `BraveAutoConfiguration`
* Renamed `TraceOtelAutoConfiguration` to `OtelAutoConfiguration`
* Removed all `NoOp` implementations of the API
2020-11-23 15:39:13 +01:00
buildmaster
791b397964 Bumping versions 2020-11-17 05:31:08 +00:00
Marcin Grzejszczak
fa4832709b Fixed conditions for sampling 2020-11-16 16:22:26 +01:00
Marcin Grzejszczak
06d353f155 Migrated to OTel 0.10.0 2020-11-06 14:59:11 +01:00
Marcin Grzejszczak
6e306e594d Abstract tracer implementations via an API (#1757)
Spring Cloud Sleuth currently is an autoconfiguration over Brave. It also consists of various instrumentation mechanisms for libraries that are not supported by Brave (e.g. Spring Cloud Circuitbreaker).

We would like to abstract Brave so that Spring Cloud Sleuth becomes an autoconfiguration for any tracer implementation that is compatible with Spring Cloud Sleuth. That way Spring Cloud Sleuth in its core module would consist of an API and various tracer implementations would implement that API which would also allow automatic instrumentation of libraries that are supported by Spring Cloud Sleuth.

## OpenTelemetry Support

Thanks to doing this abstraction we are able to support new tracer implementations, not only Brave. We've decided to add support for the OpenTelemetry SDK as the second one. If in the future if we decide to add new tracers then it will be just a matter of adding a new module that bridges to the Spring Cloud Sleuth one. Thanks to abstraction of tests as well we will be easily able to plug that tracer mechanism into our current suite of tests.
2020-10-23 08:50:23 +02:00
buildmaster
05461159eb Bumping versions 2020-09-17 05:29:17 +00:00
Marcin Grzejszczak
eca49777fb Fix 2020-07-21 21:33:24 +02:00
Marcin Grzejszczak
bd149ce4a7 Improvement with Reactor instrumentation
- adds Spring Cloud Function instrumentation
- adds Operators to manually provide instrumentation for Fluxes
- introduces Manual instrumentation mode for Reactor

TODO: Documentation (will add it soon)

related gh-1684
2020-07-21 19:06:55 +02:00
Marcin Grzejszczak
8df10ae54d Merge branch '2.2.x' 2020-07-16 11:14:38 +02:00
Adrian Cole
4c90b872a7 Makes a nice toString on RestTemplateSender (#1686)
The AsyncZipkinSpanHandler calls 'check' once on startup to let someone
know an error that may affect tracing up front. Before, this didn't
include the endpoint so it is less obvious what could be the problem.

Ex people goof the URL (don't add /api/v2/spans or it is added twice)
2020-07-14 13:27:51 +02:00
Marcin Grzejszczak
f6ad2d8969 Polish 2020-06-17 16:10:45 +02:00
Marcin Grzejszczak
5c9f8a7618 Fixes the case where the sender is overriden with the predefined name; fixes gh-1637 2020-06-17 16:05:56 +02:00
Adrian Cole
4ed3db9a27 Drops zipkin dependency from spring-cloud-sleuth-core (#1649)
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
2020-05-19 08:22:54 +08:00
Adrian Cole
30bc36ea81 Last deprecation cleanup on master (3.x) (#1646) 2020-05-18 21:51:00 +08:00
Adrian Cole
a27d634645 Hides exposed configuration and properties types (#1642)
This completes #1638 by addressing deprecations on master (3.x)
2020-05-17 21:30:45 +08:00
Adrian Cole
d59de19e97 Merge branch '2.2.x' 2020-05-17 20:49:59 +08:00
Adrian Cole
048227806a undeprecate the entry-level zipkin things as they are documented 2020-05-17 20:48:03 +08:00
Adrian Cole
eca5ea6db0 Merge branch '2.2.x' 2020-05-16 16:31:42 +08:00
Adrian Cole
8ae5e13d31 Merge branch '2.2.x' 2020-05-16 15:15:37 +08:00
Adrian Cole
c1a83aa5bb Replaces deprecated note on Properties with TODO to hide them in 3.x (#1639)
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.
2020-05-16 14:37:45 +08:00
Adrian Cole
b1d39ce291 Updates to Brave 5.12 and introduces SpanHandler (#1632)
`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
2020-05-16 14:01:38 +08:00
Adrian Cole
d4088dec9c Deprecates unnecessarily public types to ease burden (#1638)
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.
2020-05-16 13:09:24 +08:00
Adrian Cole
0290437330 Makes it more clear what the timeout code is doing and backfills tests (#1636)
I was surprised to see an executor service created just to make a time
limiter. This does it more simply and backfills the missing tests.
2020-05-15 20:26:19 +08:00
Adrian Cole
6fb92a5f66 Merge branch '2.2.x' 2020-04-23 19:42:38 +08:00
Adrian Cole
b146067b51 Merge branch '2.2.x' 2020-04-22 19:36:25 +08:00
Adrian Cole
16fb8e3ac6 Moves responsibility to import SamplerAutoConfiguration to core
Before, spring-cloud-sleuth-zipkin had to import `SamplerAutoConfiguration`
directly to unwind a sampler ordering problem caused by `TraceAutoConfiguration`
defining the default `Sampler` bean.

This fixes that by moving the default `Sampler` to where it belongs
(`SamplerAutoConfiguration`) and having `TraceAutoConfiguration` import
the sampling configuration directly as opposed to relying on auto-configuration
ordering. Finally it removes the mistake of setting `SamplerAutoConfiguration`
as auto-configuration in the first place.

The name `SamplerAutoConfiguration` was left alone because changing it would
interfere with 3rd party code that formerly imported it to correct this issue
in their non-zipkin setups.

Fixes #1618
2020-04-22 19:04:19 +08:00
Adrian Cole
44a7f4b7ad Reorganizes code under o.s.c.sleuth.baggage
This moves code and properties under org.springframework.cloud.sleuth.baggage
Properties are now under "spring.sleuth.baggage"

Those coming from 2.x should migrate with the following:
 * spring.sleuth.baggage-keys -> `BaggagePropagationCustomizer`
 * spring.sleuth.local-keys -> spring.sleuth.baggage.local-fields
 * spring.sleuth.propagation-keys -> spring.sleuth.baggage.remote-fields
 * spring.sleuth.propagation.tag.whitelisted-keys -> spring.sleuth.baggage.tag-fields
 * spring.sleuth.log.slf4j.whitelisted-mdc-keys -> spring.sleuth.baggage.correlation-fields
 * spring.sleuth.log.slf4j.enabled -> spring.sleuth.baggage.correlation-enabled

Those using MDC should know that for performance reasons, we no longer
set the following fields: `parentId` `spanExportable`.

We also do not set fields to "dirty" by default. Doing this by default
raised the overhead substantially, especially in reactive applications.

Those who want sleuth to override manual `MDC.put` operations as
described in #1416, or with to add back `parentId` `spanExportable` need
to define their own bean:

Ex. this is the former setup:

```java
@Bean CorrelationScopeDecorator oldConfig(List<String> myFieldNames) {
	CorrelationScopeDecorator.Builder builder = MDCScopeDecorator.newBuilder().clear()
			.add(SingleCorrelationField.create(BaggageFields.TRACE_ID))
			.add(SingleCorrelationField.create(BaggageFields.PARENT_ID))
			.add(SingleCorrelationField.create(BaggageFields.SPAN_ID))
			.add(SingleCorrelationField.newBuilder(BaggageFields.SAMPLED)
					.name("spanExportable").build());

        // Set all fields dirty, so that any changes made by MDC directly are reverted.
	for (String name : myFieldNames) {
		builder.add(SingleCorrelationField.newBuilder(BaggageField.create(name))
				.dirty().build());
	}
	return builder.build();
}

```
2020-04-06 23:06:10 +08:00
Marcin Grzejszczak
e7a84d5a13 Fixed javadocs 2020-03-30 14:52:29 +02:00
Marcin Grzejszczak
3ce018bc51 Upgrades to JUnit5; fixes gh-1567 2020-03-03 19:53:57 +01:00
Marcin Grzejszczak
0d237b564f Removed deprecated apis; fixes gh-1564 2020-02-18 13:30:00 +01:00
Marcin Grzejszczak
b65e7ca20e Merge branch '2.2.x' 2020-02-18 12:23:14 +01:00
Marcin Grzejszczak
eff71d4f22 Moved more beans to the conditional on backward compatibility autoconfig; fixes gh-1555 2020-02-18 12:22:13 +01:00
Marcin Grzejszczak
34f61908fd Update auto-configuration to use @Configuration(proxyBeanMethods=false)
fixes gh-1245
2019-10-24 13:42:00 +02:00
Marcin Grzejszczak
400be4130e Merge branch '2.1.x' 2019-10-23 14:18:42 +02:00
Marcin Grzejszczak
759ac87481 Not using loadbalancer zipkin URI extractor when zipkin url contains a port
fixes gh-1474
2019-10-23 13:41:24 +02:00
Marcin Grzejszczak
38ffcbc932 Added parametrization of RabbitMQ brokers (#1448)
without this change we're reusing the same broker for application logic and sending spans to zipkin
with this change we're adding a property to allow providing a different set of addresses for brokers to send spans to Zipkin

fixes gh-1210
2019-09-25 09:26:05 +02:00
Marcin Grzejszczak
2e6ae5d314 RestTempalte customizer can return an instance of rest template; fixes gh-1440 (#1446) 2019-09-19 09:26:07 +02:00
Marcin Grzejszczak
42964bf642 Rabbit sender for Zipkin is opt in; fixes gh-1432 2019-09-06 15:55:42 +02:00
Marcin Grzejszczak
59216c32f7 Calling asyncreporter#check upon bean registration (#1413)
fixes gh-1411
2019-07-31 22:53:14 +02:00
Marcin Grzejszczak
a912000f0f Added option to send spans to Zipkin over ActiveMQ
fixes gh-1380
2019-07-29 12:32:38 +02:00
Marcin Grzejszczak
50115d9c9e Merge branch '2.1.x' 2019-07-02 09:46:57 +02:00
liaochuntao
c6f03191e8 Invalid property name resolution fix
fixes gh-1376
2019-07-02 08:51:49 +02:00
Adrian Cole
a5d8893baa Updates to latest Brave (#1373) 2019-06-15 23:49:26 +08:00
Adrian Cole
516963cd2f Updates to latest Brave (#1373) 2019-06-15 23:16:08 +08:00
Marcin Grzejszczak
f29c05fb8f Merge branch '2.1.x' 2019-04-25 18:44:19 +04:00
Marcin Grzejszczak
1b493e602a Added tracing for TopicConnection for JMS
fixes gh-1324
2019-04-05 09:50:43 +02:00