Class: ZipkinTracer::Config
- Inherits:
-
Object
- Object
- ZipkinTracer::Config
- Defined in:
- lib/zipkin-tracer/config.rb
Overview
Configuration of this gem. It reads the configuration and provides default values
Instance Attribute Summary collapse
-
#annotate_plugin ⇒ Object
readonly
Returns the value of attribute annotate_plugin.
-
#async ⇒ Object
readonly
Returns the value of attribute async.
-
#check_routes ⇒ Object
readonly
Returns the value of attribute check_routes.
-
#filter_plugin ⇒ Object
readonly
Returns the value of attribute filter_plugin.
-
#json_api_host ⇒ Object
readonly
Returns the value of attribute json_api_host.
-
#kafka_producer ⇒ Object
readonly
Returns the value of attribute kafka_producer.
-
#kafka_topic ⇒ Object
readonly
Returns the value of attribute kafka_topic.
-
#log_tracing ⇒ Object
readonly
Returns the value of attribute log_tracing.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#rabbit_mq_connection ⇒ Object
readonly
Returns the value of attribute rabbit_mq_connection.
-
#rabbit_mq_exchange ⇒ Object
readonly
Returns the value of attribute rabbit_mq_exchange.
-
#rabbit_mq_routing_key ⇒ Object
readonly
Returns the value of attribute rabbit_mq_routing_key.
-
#sample_rate ⇒ Object
readonly
Returns the value of attribute sample_rate.
-
#sampled_as_boolean ⇒ Object
readonly
Returns the value of attribute sampled_as_boolean.
-
#service_name ⇒ Object
readonly
Returns the value of attribute service_name.
-
#sqs_queue_name ⇒ Object
readonly
Returns the value of attribute sqs_queue_name.
-
#sqs_region ⇒ Object
readonly
Returns the value of attribute sqs_region.
-
#trace_id_128bit ⇒ Object
readonly
Returns the value of attribute trace_id_128bit.
-
#whitelist_plugin ⇒ Object
readonly
Returns the value of attribute whitelist_plugin.
-
#write_b3_single_format ⇒ Object
readonly
Returns the value of attribute write_b3_single_format.
-
#zookeeper ⇒ Object
readonly
Returns the value of attribute zookeeper.
Instance Method Summary collapse
- #adapter ⇒ Object
-
#initialize(app, config_hash) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(app, config_hash) ⇒ Config
Returns a new instance of Config.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/zipkin-tracer/config.rb', line 13 def initialize(app, config_hash) config = config_hash || Application.config(app) # The name of the current service @service_name = config[:service_name] # The address of the Zipkin server which we will send traces to @json_api_host = config[:json_api_host] # Zookeeper information @zookeeper = config[:zookeeper] # Kafka producer information @kafka_producer = config[:producer] @kafka_topic = config[:topic] if present?(config[:topic]) # Amazon SQS queue information @sqs_queue_name = config[:sqs_queue_name] @sqs_region = config[:sqs_region] # Rabbit MQ information @rabbit_mq_connection = config[:rabbit_mq_connection] @rabbit_mq_exchange = config[:rabbit_mq_exchange] @rabbit_mq_routing_key = config[:rabbit_mq_routing_key] # Percentage of traces which by default this service traces (as float, 1.0 means 100%) @sample_rate = config[:sample_rate] || DEFAULTS[:sample_rate] # A block of code which can be called to do extra annotations of traces @annotate_plugin = config[:annotate_plugin] # call for trace annotation # A block of code which can be called to skip traces. Skip tracing if returns false @filter_plugin = config[:filter_plugin] # A block of code which can be called to force sampling. Forces sampling if returns true @whitelist_plugin = config[:whitelist_plugin] # be strict about checking `false` to ensure misconfigurations don't lead to accidental synchronous configurations @async = config[:async] != false @logger = config[:logger] || Application.logger # Was the logger in fact setup by the client? @log_tracing = config[:log_tracing] # When set to false, it uses 1/0 in the 'X-B3-Sampled' header, else uses true/false @sampled_as_boolean = config[:sampled_as_boolean].nil? ? DEFAULTS[:sampled_as_boolean] : config[:sampled_as_boolean] # The current default is true for compatibility but services are encouraged to move on. if @sampled_as_boolean @logger && @logger.warn("Using a boolean in the Sampled header is deprecated. Consider setting sampled_as_boolean to false") end # When set to true, only routable requests are sampled @check_routes = config[:check_routes].nil? ? DEFAULTS[:check_routes] : config[:check_routes] # When set to true, high 8-bytes will be prepended to trace_id. # The upper 4-bytes are epoch seconds and the lower 4-bytes are random. # This makes it convertible to Amazon X-Ray trace ID format v1. # (See http://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-request-tracing.html) @trace_id_128bit = config[:trace_id_128bit].nil? ? DEFAULTS[:trace_id_128bit] : config[:trace_id_128bit] # When set to true, only writes a single b3 header for outbound propagation. @write_b3_single_format = config[:write_b3_single_format].nil? ? DEFAULTS[:write_b3_single_format] : config[:write_b3_single_format] Trace.sample_rate = @sample_rate Trace.trace_id_128bit = @trace_id_128bit Trace.write_b3_single_format = @write_b3_single_format Trace.default_endpoint = Trace::Endpoint.local_endpoint( domain_service_name(@service_name) ) end |
Instance Attribute Details
#annotate_plugin ⇒ Object (readonly)
Returns the value of attribute annotate_plugin.
8 9 10 |
# File 'lib/zipkin-tracer/config.rb', line 8 def annotate_plugin @annotate_plugin end |
#async ⇒ Object (readonly)
Returns the value of attribute async.
8 9 10 |
# File 'lib/zipkin-tracer/config.rb', line 8 def async @async end |
#check_routes ⇒ Object (readonly)
Returns the value of attribute check_routes.
8 9 10 |
# File 'lib/zipkin-tracer/config.rb', line 8 def check_routes @check_routes end |
#filter_plugin ⇒ Object (readonly)
Returns the value of attribute filter_plugin.
8 9 10 |
# File 'lib/zipkin-tracer/config.rb', line 8 def filter_plugin @filter_plugin end |
#json_api_host ⇒ Object (readonly)
Returns the value of attribute json_api_host.
8 9 10 |
# File 'lib/zipkin-tracer/config.rb', line 8 def json_api_host @json_api_host end |
#kafka_producer ⇒ Object (readonly)
Returns the value of attribute kafka_producer.
8 9 10 |
# File 'lib/zipkin-tracer/config.rb', line 8 def kafka_producer @kafka_producer end |
#kafka_topic ⇒ Object (readonly)
Returns the value of attribute kafka_topic.
8 9 10 |
# File 'lib/zipkin-tracer/config.rb', line 8 def kafka_topic @kafka_topic end |
#log_tracing ⇒ Object (readonly)
Returns the value of attribute log_tracing.
8 9 10 |
# File 'lib/zipkin-tracer/config.rb', line 8 def log_tracing @log_tracing end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
8 9 10 |
# File 'lib/zipkin-tracer/config.rb', line 8 def logger @logger end |
#rabbit_mq_connection ⇒ Object (readonly)
Returns the value of attribute rabbit_mq_connection.
8 9 10 |
# File 'lib/zipkin-tracer/config.rb', line 8 def rabbit_mq_connection @rabbit_mq_connection end |
#rabbit_mq_exchange ⇒ Object (readonly)
Returns the value of attribute rabbit_mq_exchange.
8 9 10 |
# File 'lib/zipkin-tracer/config.rb', line 8 def rabbit_mq_exchange @rabbit_mq_exchange end |
#rabbit_mq_routing_key ⇒ Object (readonly)
Returns the value of attribute rabbit_mq_routing_key.
8 9 10 |
# File 'lib/zipkin-tracer/config.rb', line 8 def rabbit_mq_routing_key @rabbit_mq_routing_key end |
#sample_rate ⇒ Object (readonly)
Returns the value of attribute sample_rate.
8 9 10 |
# File 'lib/zipkin-tracer/config.rb', line 8 def sample_rate @sample_rate end |
#sampled_as_boolean ⇒ Object (readonly)
Returns the value of attribute sampled_as_boolean.
8 9 10 |
# File 'lib/zipkin-tracer/config.rb', line 8 def sampled_as_boolean @sampled_as_boolean end |
#service_name ⇒ Object (readonly)
Returns the value of attribute service_name.
8 9 10 |
# File 'lib/zipkin-tracer/config.rb', line 8 def service_name @service_name end |
#sqs_queue_name ⇒ Object (readonly)
Returns the value of attribute sqs_queue_name.
8 9 10 |
# File 'lib/zipkin-tracer/config.rb', line 8 def sqs_queue_name @sqs_queue_name end |
#sqs_region ⇒ Object (readonly)
Returns the value of attribute sqs_region.
8 9 10 |
# File 'lib/zipkin-tracer/config.rb', line 8 def sqs_region @sqs_region end |
#trace_id_128bit ⇒ Object (readonly)
Returns the value of attribute trace_id_128bit.
8 9 10 |
# File 'lib/zipkin-tracer/config.rb', line 8 def trace_id_128bit @trace_id_128bit end |
#whitelist_plugin ⇒ Object (readonly)
Returns the value of attribute whitelist_plugin.
8 9 10 |
# File 'lib/zipkin-tracer/config.rb', line 8 def whitelist_plugin @whitelist_plugin end |
#write_b3_single_format ⇒ Object (readonly)
Returns the value of attribute write_b3_single_format.
8 9 10 |
# File 'lib/zipkin-tracer/config.rb', line 8 def write_b3_single_format @write_b3_single_format end |
#zookeeper ⇒ Object (readonly)
Returns the value of attribute zookeeper.
8 9 10 |
# File 'lib/zipkin-tracer/config.rb', line 8 def zookeeper @zookeeper end |
Instance Method Details
#adapter ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/zipkin-tracer/config.rb', line 71 def adapter if present?(@json_api_host) :json elsif present?(@zookeeper) && RUBY_PLATFORM == 'java' :kafka elsif @kafka_producer && @kafka_producer.respond_to?(:push) :kafka_producer elsif present?(@sqs_queue_name) && defined?(Aws::SQS) :sqs elsif @rabbit_mq_connection :rabbit_mq elsif !!@log_tracing :logger else nil end end |