Class: Labkit::Tracing::Factory

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

Constant Summary collapse

OPENTRACING_SCHEME =
'opentracing'

Class Method Summary collapse

Class Method Details

.create_tracer(service_name, connection_string) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/labkit/tracing/factory.rb', line 10

def self.create_tracer(service_name, connection_string)
  return unless connection_string.present?

  begin
    opentracing_details = parse_connection_string(connection_string)
    driver_name = opentracing_details[:driver_name]

    case driver_name
    when 'jaeger'
      JaegerFactory.create_tracer(service_name, opentracing_details[:options])
    else
      raise "Unknown driver: #{driver_name}"
    end

    # Can't create the tracer? Warn and continue sans tracer
  rescue StandardError => e
    warn "Unable to instantiate tracer: #{e}"
    nil
  end
end