Class: ZipkinTracer::TracerFactory
- Inherits:
-
Object
- Object
- ZipkinTracer::TracerFactory
- Defined in:
- lib/zipkin-tracer/tracer_factory.rb
Instance Method Summary collapse
-
#service_name(default_name) ⇒ Object
Use the Domain environment variable to extract the service name, otherwise use the default config name TODO: move to the config object.
- #tracer(config) ⇒ Object
Instance Method Details
#service_name(default_name) ⇒ Object
Use the Domain environment variable to extract the service name, otherwise use the default config name TODO: move to the config object
35 36 37 |
# File 'lib/zipkin-tracer/tracer_factory.rb', line 35 def service_name(default_name) ENV["DOMAIN"].to_s.empty? ? default_name : ENV["DOMAIN"].split('.').first end |
#tracer(config) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/zipkin-tracer/tracer_factory.rb', line 3 def tracer(config) adapter = config.adapter tracer = case adapter when :json require 'zipkin-tracer/zipkin_json_tracer' = { json_api_host: config.json_api_host, logger: config.logger } Trace::ZipkinJsonTracer.new() when :kafka require 'zipkin-tracer/zipkin_kafka_tracer' Trace::ZipkinKafkaTracer.new(zookeepers: config.zookeeper) when :logger require 'zipkin-tracer/zipkin_logger_tracer' Trace::ZipkinLoggerTracer.new(logger: config.logger) else require 'zipkin-tracer/zipkin_null_tracer' Trace::NullTracer.new end Trace.tracer = tracer # TODO: move this to the TracerBase and kill scribe tracer ip_format = config.adapter == :kafka ? :i32 : :string Trace.default_endpoint = Trace::Endpoint.local_endpoint( config.service_port, service_name(config.service_name), ip_format ) tracer end |