Class JaegerTracerBuilder

java.lang.Object
io.helidon.tracing.jaeger.JaegerTracerBuilder
All Implemented Interfaces:
Builder<JaegerTracerBuilder,Tracer>, TracerBuilder<JaegerTracerBuilder>, Supplier<Tracer>

public class JaegerTracerBuilder extends Object implements TracerBuilder<JaegerTracerBuilder>
The JaegerTracerBuilder is a convenience builder for Tracer to use with Jaeger.

Unless You want to explicitly depend on Jaeger in Your code, please use TracerBuilder.create(String) or TracerBuilder.create(io.helidon.config.Config) that is abstracted.

The Jaeger tracer uses environment variables and system properties to override the defaults. Except for protocol and service these are honored, unless overridden in configuration or through the builder methods. See Jaeger documentation for details.

The following table lists jaeger specific defaults and configuration options.

Tracer Configuration Options
option default description
service   Service name
protocol http The protocol to use. By default http is used.
host 127.0.0.1 Host to use
port 14250 Port to be used
path   Path to be used.
exporter-timeout 10 seconds Timeout of exporter
private-key-pem   Client private key in PEM format
client-cert-pem   Client certificate in PEM format
trusted-cert-pem   Trusted certificates in PEM format
sampler-type const with param set to 1 Sampler type const (0 to disable, 1 to always enabled), ratio (sample param contains the ratio as a double)
sampler-param sampler type default Numeric parameter specifying details for the sampler type.
tags   see TracerBuilder
boolean-tags   see TracerBuilder
int-tags   see TracerBuilder
  • Constructor Details

    • JaegerTracerBuilder

      protected JaegerTracerBuilder()
      Default constructor, does not modify any state.
  • Method Details

    • forService

      public static JaegerTracerBuilder forService(String serviceName)
      Get a Jaeger Tracer 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 Jaeger.
    • create

      public static JaegerTracerBuilder 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:
    • serviceName

      public JaegerTracerBuilder serviceName(String name)
      Description copied from interface: TracerBuilder
      Service name of the traced service.
      Specified by:
      serviceName in interface TracerBuilder<JaegerTracerBuilder>
      Parameters:
      name - name of the service using the tracer
      Returns:
      updated builder instance
    • collectorProtocol

      public JaegerTracerBuilder collectorProtocol(String protocol)
      Description copied from interface: TracerBuilder
      Protocol to use (such as http or https) to connect to tracing collector. Default is defined by each tracing integration.
      Specified by:
      collectorProtocol in interface TracerBuilder<JaegerTracerBuilder>
      Parameters:
      protocol - protocol to use
      Returns:
      updated builder instance
    • collectorPort

      public JaegerTracerBuilder 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 interface TracerBuilder<JaegerTracerBuilder>
      Parameters:
      port - port to use
      Returns:
      updated builder instance
    • collectorPath

      public JaegerTracerBuilder collectorPath(String path)
      Description copied from interface: TracerBuilder
      Path on the collector host to use when sending data to tracing collector. Default is defined by each tracing integration.
      Specified by:
      collectorPath in interface TracerBuilder<JaegerTracerBuilder>
      Parameters:
      path - path to use
      Returns:
      updated builder instance
    • collectorHost

      public JaegerTracerBuilder 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 interface TracerBuilder<JaegerTracerBuilder>
      Parameters:
      host - host to use
      Returns:
      updated builder instance
    • addTracerTag

      public JaegerTracerBuilder addTracerTag(String key, String value)
      Description copied from interface: TracerBuilder
      Tracer level tags that get added to all reported spans.
      Specified by:
      addTracerTag in interface TracerBuilder<JaegerTracerBuilder>
      Parameters:
      key - name of the tag
      value - value of the tag
      Returns:
      updated builder instance
    • addTracerTag

      public JaegerTracerBuilder addTracerTag(String key, Number value)
      Description copied from interface: TracerBuilder
      Tracer level tags that get added to all reported spans.
      Specified by:
      addTracerTag in interface TracerBuilder<JaegerTracerBuilder>
      Parameters:
      key - name of the tag
      value - numeric value of the tag
      Returns:
      updated builder instance
    • addTracerTag

      public JaegerTracerBuilder addTracerTag(String key, boolean value)
      Description copied from interface: TracerBuilder
      Tracer level tags that get added to all reported spans.
      Specified by:
      addTracerTag in interface TracerBuilder<JaegerTracerBuilder>
      Parameters:
      key - name of the tag
      value - boolean value of the tag
      Returns:
      updated builder instance
    • config

      public JaegerTracerBuilder 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 interface TracerBuilder<JaegerTracerBuilder>
      Parameters:
      config - configuration node of the tracer configuration
      Returns:
      updated builder instance
    • privateKey

      public JaegerTracerBuilder privateKey(Resource resource)
      Private key in PEM format.
      Parameters:
      resource - key resource
      Returns:
      updated builder
    • clientCertificate

      public JaegerTracerBuilder clientCertificate(Resource resource)
      Certificate of client in PEM format.
      Parameters:
      resource - certificate resource
      Returns:
      updated builder
    • trustedCertificates

      public JaegerTracerBuilder trustedCertificates(Resource resource)
      Trusted certificates in PEM format.
      Parameters:
      resource - trusted certificates resource
      Returns:
      updated builder
    • spanProcessorType

      public JaegerTracerBuilder spanProcessorType(JaegerTracerBuilder.SpanProcessorType spanProcessorType)
      Span Processor type used.
      Parameters:
      spanProcessorType - to use
      Returns:
      updated builder
    • exporterTimeout

      public JaegerTracerBuilder exporterTimeout(Duration exporterTimeout)
      Timeout of exporter requests.
      Parameters:
      exporterTimeout - timeout to use
      Returns:
      updated builder
    • scheduleDelay

      public JaegerTracerBuilder scheduleDelay(Duration scheduleDelay)
      Schedule Delay of exporter requests.
      Parameters:
      scheduleDelay - timeout to use
      Returns:
      updated builder
    • maxQueueSize

      public JaegerTracerBuilder maxQueueSize(int maxQueueSize)
      Maximum Queue Size of exporter requests.
      Parameters:
      maxQueueSize - to use
      Returns:
      updated builder
    • maxExportBatchSize

      public JaegerTracerBuilder maxExportBatchSize(int maxExportBatchSize)
      Maximum Export Batch Size of exporter requests.
      Parameters:
      maxExportBatchSize - to use
      Returns:
      updated builder
    • enabled

      public JaegerTracerBuilder 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 interface TracerBuilder<JaegerTracerBuilder>
      Parameters:
      enabled - set to false to disable distributed tracing
      Returns:
      updated builder instance
    • registerGlobal

      public JaegerTracerBuilder registerGlobal(boolean global)
      Description copied from interface: TracerBuilder
      When enabled, the created instance is also registered as a global tracer.
      Specified by:
      registerGlobal in interface TracerBuilder<JaegerTracerBuilder>
      Parameters:
      global - whether to register this tracer as a global tracer once built
      Returns:
      updated builder instance
    • unwrap

      public <B> B unwrap(Class<B> builderClass)
      Description copied from interface: TracerBuilder
      Access the underlying builder by specific type. This is a dangerous operation that will succeed only if the builder contains the expected type. This practically removes abstraction capabilities of this builder.
      Specified by:
      unwrap in interface TracerBuilder<JaegerTracerBuilder>
      Type Parameters:
      B - type of the builder
      Parameters:
      builderClass - type to access
      Returns:
      instance of the builder
    • samplerParam

      public JaegerTracerBuilder samplerParam(Number samplerParam)
      The sampler parameter (number).
      Parameters:
      samplerParam - parameter of the sampler
      Returns:
      updated builder instance
    • samplerType

      public JaegerTracerBuilder samplerType(JaegerTracerBuilder.SamplerType samplerType)
      Sampler type.

      See Sampler types.

      Parameters:
      samplerType - type of the sampler
      Returns:
      updated builder instance
    • addPropagation

      public JaegerTracerBuilder addPropagation(JaegerTracerBuilder.PropagationFormat propagationFormat)
      Add propagation format to use. Default propagation is b3 and jaeger, to be compatible both with 3.0 (backward), and with 4.x, which uses jaeger as default. If any propagation is specified either in configuration or through this method, defaults will not be honored.
      Parameters:
      propagationFormat - propagation value
      Returns:
      updated builder instance
    • build

      public Tracer build()
      Builds the Tracer for Jaeger based on the configured parameters.
      Specified by:
      build in interface Builder<JaegerTracerBuilder,Tracer>
      Returns:
      the tracer