Class: Labkit::Tracing::Factory

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

Overview

Factory provides tools for setting up and configuring the distributed tracing system within the process, given the tracing connection string

Constant Summary collapse

OPENTRACING_SCHEME =
"opentracing"

Class Method Summary collapse

Class Method Details

.create_tracer(service_name, connection_string) ⇒ Object



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

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