Class: ZipkinTracer::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/zipkin-tracer/config.rb

Overview

Configuration of this gem. It reads the configuration and provides default values

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, config_hash) ⇒ Config

Returns a new instance of Config.



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/zipkin-tracer/config.rb', line 11

def initialize(app, config_hash)
  config = config_hash || Application.config(app)
  @service_name      = config[:service_name]
  @service_port      = config[:service_port]      || DEFAULTS[:service_port]
  @json_api_host     = config[:json_api_host]
  @zookeeper         = config[:zookeeper]
  @sample_rate       = config[:sample_rate]       || DEFAULTS[:sample_rate]
  @annotate_plugin   = config[:annotate_plugin]   # call for trace annotation
  @filter_plugin     = config[:filter_plugin]     # skip tracing if returns false
  @whitelist_plugin  = config[:whitelist_plugin]  # force sampling if returns true
  @logger            = Application.logger
  @log_tracing       = config[:log_tracing]       # Was the logger in fact setup by the client?
end

Instance Attribute Details

#annotate_pluginObject (readonly)

Returns the value of attribute annotate_plugin.



7
8
9
# File 'lib/zipkin-tracer/config.rb', line 7

def annotate_plugin
  @annotate_plugin
end

#filter_pluginObject (readonly)

Returns the value of attribute filter_plugin.



7
8
9
# File 'lib/zipkin-tracer/config.rb', line 7

def filter_plugin
  @filter_plugin
end

#json_api_hostObject (readonly)

Returns the value of attribute json_api_host.



7
8
9
# File 'lib/zipkin-tracer/config.rb', line 7

def json_api_host
  @json_api_host
end

#log_tracingObject (readonly)

Returns the value of attribute log_tracing.



7
8
9
# File 'lib/zipkin-tracer/config.rb', line 7

def log_tracing
  @log_tracing
end

#loggerObject (readonly)

Returns the value of attribute logger.



7
8
9
# File 'lib/zipkin-tracer/config.rb', line 7

def logger
  @logger
end

#sample_rateObject (readonly)

Returns the value of attribute sample_rate.



7
8
9
# File 'lib/zipkin-tracer/config.rb', line 7

def sample_rate
  @sample_rate
end

#service_nameObject (readonly)

Returns the value of attribute service_name.



7
8
9
# File 'lib/zipkin-tracer/config.rb', line 7

def service_name
  @service_name
end

#service_portObject (readonly)

Returns the value of attribute service_port.



7
8
9
# File 'lib/zipkin-tracer/config.rb', line 7

def service_port
  @service_port
end

#whitelist_pluginObject (readonly)

Returns the value of attribute whitelist_plugin.



7
8
9
# File 'lib/zipkin-tracer/config.rb', line 7

def whitelist_plugin
  @whitelist_plugin
end

#zookeeperObject (readonly)

Returns the value of attribute zookeeper.



7
8
9
# File 'lib/zipkin-tracer/config.rb', line 7

def zookeeper
  @zookeeper
end

Instance Method Details

#adapterObject



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/zipkin-tracer/config.rb', line 25

def adapter
  if present?(@json_api_host)
    :json
  elsif present?(@zookeeper) && RUBY_PLATFORM == 'java'
    :kafka
  elsif !!@log_tracing
    :logger
  else
    nil
  end
end