io.opentracing.contrib:opentracing-spring-zipkin-starter

OpenTracing Spring Boot Starter for Zipkin

License

License

Categories

Categories

Zipkin Application Testing & Monitoring Application Performance Monitoring (APM)
GroupId

GroupId

io.opentracing.contrib
ArtifactId

ArtifactId

opentracing-spring-zipkin-starter
Last Version

Last Version

0.2.0
Release Date

Release Date

Type

Type

jar
Description

Description

OpenTracing Spring Boot Starter for Zipkin

Download opentracing-spring-zipkin-starter

How to add to project

<!-- https://jarcasting.com/artifacts/io.opentracing.contrib/opentracing-spring-zipkin-starter/ -->
<dependency>
    <groupId>io.opentracing.contrib</groupId>
    <artifactId>opentracing-spring-zipkin-starter</artifactId>
    <version>0.2.0</version>
</dependency>
// https://jarcasting.com/artifacts/io.opentracing.contrib/opentracing-spring-zipkin-starter/
implementation 'io.opentracing.contrib:opentracing-spring-zipkin-starter:0.2.0'
// https://jarcasting.com/artifacts/io.opentracing.contrib/opentracing-spring-zipkin-starter/
implementation ("io.opentracing.contrib:opentracing-spring-zipkin-starter:0.2.0")
'io.opentracing.contrib:opentracing-spring-zipkin-starter:jar:0.2.0'
<dependency org="io.opentracing.contrib" name="opentracing-spring-zipkin-starter" rev="0.2.0">
  <artifact name="opentracing-spring-zipkin-starter" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.opentracing.contrib', module='opentracing-spring-zipkin-starter', version='0.2.0')
)
libraryDependencies += "io.opentracing.contrib" % "opentracing-spring-zipkin-starter" % "0.2.0"
[io.opentracing.contrib/opentracing-spring-zipkin-starter "0.2.0"]

Dependencies

compile (6)

Group / Artifact Type Version
io.opentracing.contrib : opentracing-spring-tracer-configuration-starter jar 0.1.0
org.springframework.boot : spring-boot-autoconfigure Optional jar
org.springframework.boot : spring-boot-configuration-processor Optional jar
io.opentracing : opentracing-api jar 0.31.0
io.opentracing.brave : brave-opentracing jar 0.31.3
io.zipkin.reporter2 : zipkin-sender-okhttp3 jar 2.6.0

test (6)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter-test jar
org.springframework.boot : spring-boot-starter-logging jar
org.springframework.boot : spring-boot-starter-web jar
io.opentracing : opentracing-mock jar 0.31.0
org.awaitility : awaitility jar 3.0.0
io.zipkin.zipkin2 : zipkin-junit jar 2.10.4

Project Modules

There are no modules declared in this project.

Build Status Released Version

Dependencies

The opentracing-spring-zipkin-starter simply contains the code needed to provide a Zipkin implementation of the OpenTracing's io.opentracing.Tracer interface.

For a project to be able to actually instrument a Spring stack, one or more of the purpose built starters (like io.opentracing.contrib:opentracing-spring-web-starter or io.opentracing.contrib:opentracing-spring-cloud-starter)
would also have to be included in the POM.

The opentracing-spring-zipkin-web-starter starter is convenience starter that includes both opentracing-spring-zipkin-starter and opentracing-spring-web-starter This means that by including it, simple web Spring Boot microservices include all the necessary dependencies to instrument Web requests / responses and send traces to Zipkin.

The opentracing-spring-zipkin-cloud-starter starter is convenience starter that includes both opentracing-spring-zipkin-starter and opentracing-spring-cloud-starter This means that by including it, all parts of the Spring Cloud stack supported by Opentracing will be instrumented

Configuration

<dependency>
  <groupId>io.opentracing.contrib</groupId>
  <artifactId>opentracing-spring-zipkin-web-starter</artifactId>
</dependency>

or

<dependency>
  <groupId>io.opentracing.contrib</groupId>
  <artifactId>opentracing-spring-zipkin-cloud-starter</artifactId>
</dependency>

Either dependency will ensure that Spring Boot will auto configure a Zipkin implementation of OpenTracing's Tracer when the application starts.

By default, the Zipkin server is expected to collect traces at http://localhost:9411/api/v2/spans encoded with JSON_V2. To change the default simply set the following the property:

opentracing.zipkin.http-sender.baseUrl=http://<host>:<port>

Configuration options

All the available configuration options can be seen in ZipkinConfigurationProperties. The prefix to be used for these properties is opentracing.zipkin. Furthermore, the service name is configured via the standard Spring Cloud spring.application.name property.

Beware to use the correct syntax for properties that are camel-case in ZipkinConfigurationProperties.

  • For properties / yaml files use -. For example opentracing.zipkin.http-sender.url=http://somehost:someport
  • For environment variables use _. For example OPENTRACING_ZIPKIN_HTTP_SENDER_URL=http://somehost:someport

Defaults

If no configuration options are changed and the user does not manually provide any of the beans that the auto-configuration process provides, the following defaults are used:

  • unknown-spring-boot Will be used as the service-name if no value has been specified to the property spring.application.name.
  • Sampler.ALWAYS_SAMPLE
  • AsyncReporter (using an OkHttpSender)

Common cases

Set service name

Set spring.application.name to the desired name

Sampling

  • Boundary sampler

    opentracing.zipkin.boundary-sampler.rate = value

    Where value is between 0.0 (no sampling) and 1.0 (sampling of every request)

  • Counting sampler

    opentracing.zipkin.counting-sampler.rate = value

    Where value is between 0.0 (no sampling) and 1.0 (sampling of every request)

The samplers above are mutually exclusive.

A custom sampler could of course be provided by declaring a bean of type brave.sampler.Sampler

Reporter

By default starter configures AsyncRepoter using OkHttpSender with JSON_V2 encoding. Following properties can be changed to configure the reporter.

  • opentracing.zipkin.http-sender.encoder - encoding of spans e.g. JSON_V1, JSON_V2, PROTO3
  • opentracing.zipkin.http-sender.baseUrl - set base url e.g. http://zipkin:9411/

Advanced cases

Manual bean provisioning

Any of the following beans can be provided by the application (by adding configuring them as bean with @Bean for example) and will be used to by the Tracer instead of the auto-configured beans.

  • brave.sampler.Sampler
  • zipkin2.reporter.Reporter

brave.Tracing.Builder customization

Right before the Tracer is created, it is possible to provide arbitrary customizations to Tracing.Builder by providing a bean of type ZipkinTracerCustomizer

Caution

Beware of the default sampler in production

In a high traffic environment, the default sampler that is configured is very unsafe since it samples every request. It is therefore highly recommended to explicitly configure on of the other options in a production environment

Development

Maven checkstyle plugin is used to maintain consistent code style based on Google Style Guides

./mvnw clean install

Release

Follow instructions in RELEASE

License

Apache 2.0 License.

io.opentracing.contrib

3rd-Party OpenTracing API Contributions

3rd-party contributions that use OpenTracing. **The repositories in this org are *not* affiliated with the CNCF.**

Versions

Version
0.2.0
0.1.4
0.1.3
0.1.2
0.1.1