Package io.helidon.tracing.zipkin
Class ZipkinTracerBuilder
- java.lang.Object
-
- io.helidon.tracing.zipkin.ZipkinTracerBuilder
-
- All Implemented Interfaces:
Builder<Tracer>
,TracerBuilder<ZipkinTracerBuilder>
,Supplier<Tracer>
public class ZipkinTracerBuilder extends Object implements TracerBuilder<ZipkinTracerBuilder>
The ZipkinTracerBuilder is a convenience builder forTracer
to use with Zipkin.Unless You want to explicitly depend on Zipkin in Your code, please use
TracerBuilder.create(String)
orTracerBuilder.create(Config)
that is abstracted.The following table lists zipkin specific defaults and configuration options.
Tracer Configuration Options option default description api-version
2 Version of the Zipkin API to use, currently supports 1 and 2 service
Required service name protocol
http
see TracerBuilder
host
127.0.0.1
see TracerBuilder
port
9411 see TracerBuilder
path
/api/v2/spans
Default for ZipkinTracerBuilder.Version.V2
, which is the default versiontags
see TracerBuilder
boolean-tags
see TracerBuilder
int-tags
see TracerBuilder
- See Also:
- Zipkin Attributes, Zipkin Missing Service Name
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ZipkinTracerBuilder.Version
Versions available for Zipkin API.
-
Constructor Summary
Constructors Modifier Constructor Description protected
ZipkinTracerBuilder()
Default constructor, does not modify state.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ZipkinTracerBuilder
addTracerTag(String key, boolean value)
Tracer level tags that get added to all reported spans.ZipkinTracerBuilder
addTracerTag(String key, Number value)
Tracer level tags that get added to all reported spans.ZipkinTracerBuilder
addTracerTag(String key, String value)
Tracer level tags that get added to all reported spans.Tracer
build()
Builds theTracer
for Zipkin based on the configured parameters.Tracer
buildAndRegister()
Build and register as a global tracer.ZipkinTracerBuilder
collectorHost(String host)
Host to use to connect to tracing collector.ZipkinTracerBuilder
collectorPath(String path)
Override path to use.ZipkinTracerBuilder
collectorPort(int port)
Port to use to connect to tracing collector.ZipkinTracerBuilder
collectorProtocol(String protocol)
Protocol to use (such ashttp
orhttps
) to connect to tracing collector.ZipkinTracerBuilder
collectorUri(URI uri)
Set the collector URI used for sending tracing data.ZipkinTracerBuilder
config(Config config)
Load configuration of tracer from configuration of the application.static ZipkinTracerBuilder
create(Config config)
Create a new builder based on values in configuration.ZipkinTracerBuilder
enabled(boolean enabled)
When enabled, tracing will be sent.static ZipkinTracerBuilder
forService(String serviceName)
Get a ZipkinTracer
builder for processing tracing data of a service with a given name.ZipkinTracerBuilder
registerGlobal(boolean global)
When enabled, the created instance is also registered as a global tracer.ZipkinTracerBuilder
sender(Sender sender)
The sender to use for sending events to Zipkin.ZipkinTracerBuilder
serviceName(String name)
Service name of the traced service.ZipkinTracerBuilder
version(ZipkinTracerBuilder.Version version)
Version of Zipkin API to use.
-
-
-
Method Detail
-
forService
public static ZipkinTracerBuilder forService(String serviceName)
Get a ZipkinTracer
builder for processing tracing data of a service with a given name.- Parameters:
serviceName
- name of the service that will be using the tracer.- Returns:
Tracer
builder for Zipkin.
-
create
public static ZipkinTracerBuilder create(Config config)
Create a new builder based on values in configuration. This requires at least a key "service" in the provided config.- Parameters:
config
- configuration to load this builder from- Returns:
- a new builder instance.
- See Also:
config(Config)
-
serviceName
public ZipkinTracerBuilder serviceName(String name)
Description copied from interface:TracerBuilder
Service name of the traced service.- Specified by:
serviceName
in interfaceTracerBuilder<ZipkinTracerBuilder>
- Parameters:
name
- name of the service using the tracer- Returns:
- updated builder instance
-
collectorUri
public ZipkinTracerBuilder collectorUri(URI uri)
Description copied from interface:TracerBuilder
Set the collector URI used for sending tracing data.Default implementation configures
TracerBuilder.collectorProtocol(String)
,TracerBuilder.collectorHost(String)
,TracerBuilder.collectorPath(String)
andTracerBuilder.collectorPort(int)
if configured in the uri.- Specified by:
collectorUri
in interfaceTracerBuilder<ZipkinTracerBuilder>
- Parameters:
uri
- the endpoint of the tracing collector- Returns:
- updated builder instance
-
collectorProtocol
public ZipkinTracerBuilder collectorProtocol(String protocol)
Description copied from interface:TracerBuilder
Protocol to use (such ashttp
orhttps
) to connect to tracing collector. Default is defined by each tracing integration.- Specified by:
collectorProtocol
in interfaceTracerBuilder<ZipkinTracerBuilder>
- Parameters:
protocol
- protocol to use- Returns:
- updated builder instance
-
collectorHost
public ZipkinTracerBuilder collectorHost(String host)
Description copied from interface:TracerBuilder
Host to use to connect to tracing collector. Default is defined by each tracing integration.- Specified by:
collectorHost
in interfaceTracerBuilder<ZipkinTracerBuilder>
- Parameters:
host
- host to use- Returns:
- updated builder instance
-
collectorPort
public ZipkinTracerBuilder collectorPort(int port)
Description copied from interface:TracerBuilder
Port to use to connect to tracing collector. Default is defined by each tracing integration.- Specified by:
collectorPort
in interfaceTracerBuilder<ZipkinTracerBuilder>
- Parameters:
port
- port to use- Returns:
- updated builder instance
-
collectorPath
public ZipkinTracerBuilder collectorPath(String path)
Override path to use. Path is usually defined by the protocolZipkinTracerBuilder.Version
. Use this to override if not using default (e.g. when Zipkin is behind a reverse proxy that prefixes the path).- Specified by:
collectorPath
in interfaceTracerBuilder<ZipkinTracerBuilder>
- Parameters:
path
- path to override the default defined byZipkinTracerBuilder.Version
- Returns:
- updated builder instance
-
enabled
public ZipkinTracerBuilder enabled(boolean enabled)
Description copied from interface:TracerBuilder
When enabled, tracing will be sent. If enabled is false, tracing should use a no-op tracer.- Specified by:
enabled
in interfaceTracerBuilder<ZipkinTracerBuilder>
- Parameters:
enabled
- set tofalse
to disable distributed tracing- Returns:
- updated builder instance
-
addTracerTag
public ZipkinTracerBuilder addTracerTag(String key, String value)
Description copied from interface:TracerBuilder
Tracer level tags that get added to all reported spans.- Specified by:
addTracerTag
in interfaceTracerBuilder<ZipkinTracerBuilder>
- Parameters:
key
- name of the tagvalue
- value of the tag- Returns:
- updated builder instance
-
addTracerTag
public ZipkinTracerBuilder addTracerTag(String key, Number value)
Description copied from interface:TracerBuilder
Tracer level tags that get added to all reported spans.- Specified by:
addTracerTag
in interfaceTracerBuilder<ZipkinTracerBuilder>
- Parameters:
key
- name of the tagvalue
- numeric value of the tag- Returns:
- updated builder instance
-
addTracerTag
public ZipkinTracerBuilder addTracerTag(String key, boolean value)
Description copied from interface:TracerBuilder
Tracer level tags that get added to all reported spans.- Specified by:
addTracerTag
in interfaceTracerBuilder<ZipkinTracerBuilder>
- Parameters:
key
- name of the tagvalue
- boolean value of the tag- Returns:
- updated builder instance
-
registerGlobal
public ZipkinTracerBuilder registerGlobal(boolean global)
Description copied from interface:TracerBuilder
When enabled, the created instance is also registered as a global tracer. When set totrue
methodTracerBuilder.build()
will have the same result asTracerBuilder.buildAndRegister()
.- Specified by:
registerGlobal
in interfaceTracerBuilder<ZipkinTracerBuilder>
- Parameters:
global
- whether to register this tracer as a global tracer once built- Returns:
- updated builder instance
-
config
public ZipkinTracerBuilder config(Config config)
Description copied from interface:TracerBuilder
Load configuration of tracer from configuration of the application. The configuration keys are specific for each tracer integration and documented in these integration projects.- Specified by:
config
in interfaceTracerBuilder<ZipkinTracerBuilder>
- Parameters:
config
- configuration node of the tracer configuration- Returns:
- updated builder instance
-
build
public Tracer build()
Builds theTracer
for Zipkin based on the configured parameters.- Specified by:
build
in interfaceBuilder<Tracer>
- Specified by:
build
in interfaceTracerBuilder<ZipkinTracerBuilder>
- Returns:
- the tracer
-
buildAndRegister
public Tracer buildAndRegister()
Description copied from interface:TracerBuilder
Build and register as a global tracer.- Specified by:
buildAndRegister
in interfaceTracerBuilder<ZipkinTracerBuilder>
- Returns:
- The
Tracer
built and registered
-
version
public ZipkinTracerBuilder version(ZipkinTracerBuilder.Version version)
Version of Zipkin API to use. Defaults toZipkinTracerBuilder.Version.V2
.- Parameters:
version
- version to use- Returns:
- updated builder instance
-
sender
public ZipkinTracerBuilder sender(Sender sender)
The sender to use for sending events to Zipkin. When configured, allcollectorProtocol(String)
,collectorHost(String)
,collectorPort(int)
, andversion(Version)
methods are ignored.- Parameters:
sender
- the sender to use- Returns:
- this builder
-
-