Class: Labkit::Tracing::JaegerFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/labkit/tracing/jaeger_factory.rb

Overview

JaegerFactory will configure Jaeger distributed tracing

Constant Summary collapse

DEFAULT_PROBABILISTIC_RATE =

When the probabilistic sampler is used, by default 0.1% of requests will be traced

0.001
DEFAULT_UDP_PORT =

The default port for the Jaeger agent UDP listener

6831
FLUSH_INTERVAL =

Reduce this from default of 10 seconds as the Ruby jaeger client doesn’t have overflow control, leading to very large messages which fail to send over UDP (max packet = 64k) Flush more often, with smaller packets

5

Class Method Summary collapse

Class Method Details

.create_tracer(service_name, options) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/labkit/tracing/jaeger_factory.rb', line 24

def self.create_tracer(service_name, options)
  # The service_name parameter from GITLAB_TRACING takes precedence over the application one
  service_name = options[:service_name] if options[:service_name]

  # parse reporter headers as necessary
  headers = build_headers(options)

  kwargs = {
    service_name: service_name,
    sampler: get_sampler(options[:sampler], options[:sampler_param]),
    reporter: get_reporter(service_name, options[:http_endpoint], options[:udp_endpoint], headers),
  }.compact

  extra_params = options.except(:sampler, :sampler_param, :http_endpoint, :udp_endpoint, :strict_parsing, :debug)
  if extra_params.present?
    message = "jaeger tracer: invalid option: #{extra_params.keys.join(", ")}"

    raise message if options[:strict_parsing]

    warn message
  end

  Jaeger::Client.build(**kwargs)
end