T - type of the builder, used so that inherited builders returned by methods
are of the correct type and contain all methods, even those not inheritec from this
interfacepublic interface TracerBuilder<T extends TracerBuilder> extends Builder<Tracer>
tracer.
Each tracer implementation may use different options, though these are the common ones.
To keep service implementation abstracted from specific tracer, use config(Config)
to load configuration of the tracer, as that supports externalization of
specific configuration options (e.g. you may use api-version for Zipkin tracer
and sampler-type for Jaeger).
The following table lists common configuration options that must be honored by each integration (if supported by it).
| option | description |
|---|---|
service |
Name of the service sending the tracing information. This is usually visible in the trace data to distinguish actors in a conversation (e.g. when multiple microservices are connected together) |
protocol |
usually http/https, see collectorProtocol(String) |
host |
host of the collector server, defaults are implementation specific, though
often "localhost" as a docker image is expected, see collectorHost(String) |
port |
port of the collector server, defaults are implementation specific.
See collectorPort(int) |
path |
Path on the collector server used to publish/send span data, defaults are implementation
specific. See collectorPath(String) |
tags |
An object config node containing key/value pairs with tag name and string tag value for
tags shared by all spans. See addTracerTag(String, String) |
boolean-tags |
An object config node containing key/value pairs with tag name and boolean tag value for
tags shared by all spans. See addTracerTag(String, boolean) |
int-tags |
An object config node containing key/value pairs with tag name and integer tag value for
tags shared by all spans. See addTracerTag(String, Number) |
Example:
tracing:
# usually must be provided, as it is used as a service identifier
service: "basket-service"
# host of the collector server - example for zipkin in docker environment
# would use default host, port and path
host: "zipkin"
# example of a tracer-wide tag
tags:
env: "stage-1"
| Modifier and Type | Method and Description |
|---|---|
T |
addTracerTag(String key,
boolean value)
Tracer level tags that get added to all reported spans.
|
T |
addTracerTag(String key,
Number value)
Tracer level tags that get added to all reported spans.
|
T |
addTracerTag(String key,
String value)
Tracer level tags that get added to all reported spans.
|
default Tracer |
buildAndRegister()
Build and register as a global tracer.
|
T |
collectorHost(String host)
Host to use to connect to tracing collector.
|
T |
collectorPath(String path)
Path on the collector host to use when sending data to tracing collector.
|
T |
collectorPort(int port)
Port to use to connect to tracing collector.
|
T |
collectorProtocol(String protocol)
Protocol to use (such as
http or https) to connect to tracing collector. |
default T |
collectorUri(URI uri)
Set the collector URI used for sending tracing data.
|
T |
config(Config config)
Load configuration of tracer from configuration of the application.
|
static TracerBuilder<?> |
create(Config config)
Create a new builder from configuration.
|
static TracerBuilder<?> |
create(String serviceName)
Create a new builder for the service name.
|
T |
enabled(boolean enabled)
When enabled, tracing will be sent.
|
T |
serviceName(String name)
Service name of the traced service.
|
static TracerBuilder<?> create(String serviceName)
serviceName - name of the service using the tracerstatic TracerBuilder<?> create(Config config)
config - configuration node to load tracer configuration fromT serviceName(String name)
name - name of the service using the tracerdefault T collectorUri(URI uri)
Default implementation configures collectorProtocol(String),
collectorHost(String), collectorPath(String) and
collectorPort(int) if configured in the uri.
uri - the endpoint of the tracing collectorT collectorProtocol(String protocol)
http or https) to connect to tracing collector.
Default is defined by each tracing integration.protocol - protocol to useT collectorPort(int port)
port - port to useT collectorHost(String host)
host - host to useT collectorPath(String path)
path - path to useT addTracerTag(String key, String value)
key - name of the tagvalue - value of the tagT addTracerTag(String key, Number value)
key - name of the tagvalue - numeric value of the tagT addTracerTag(String key, boolean value)
key - name of the tagvalue - boolean value of the tagT config(Config config)
config - configuration node of the tracer configurationT enabled(boolean enabled)
enabled - set to false to disable distributed tracingCopyright © 2018, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.