class Aws::Xray::Configuration

thread-unsafe, suppose to be used only in initialization phase.

Constants

DEFAULT_ANNOTATION

Freeze to force users to set default annotation with writer method.

DEFAULT_METADATA

Attributes

client_options[RW]

@param [Hash] client_options For xray-agent client.

- host: e.g. '127.0.0.1'
- port: e.g. 2000

@return [Hash]

default_annotation[R]

@return [Hash]

default_metadata[RW]

@param [Hash] default_metadatametadata Default metadata. @return [Hash]

excluded_paths[RW]

@param [Array<String>] excluded_paths @return [Array<String>]

logger[RW]

@param [Logger] logger @return [Logger]

name[RW]

@param [String] name Logical service name for this application. @return [String]

record_caller_of_http_requests[RW]

@param [Boolean] record_caller_of_http_requests @return [Boolean]

sampling_rate[RW]

Default is undefined. @param [Float] sampling_rate @return [Float]

segment_sending_error_handler[RW]

@param [Proc] segment_sending_error_handler Callable object

solr_hook_name[RW]

@param [String] solr_hook_name @return [String]

version[R]

@return [String]

worker[R]

@return [Aws::Xray::Worker::Configuration]

Public Class Methods

new() click to toggle source
# File lib/aws/xray/configuration.rb, line 22
def initialize
  @logger = ::Logger.new($stdout).tap {|l| l.level = Logger::INFO }
  @name = ENV['AWS_XRAY_NAME']
  @client_options =
    begin
      option = (ENV['AWS_XRAY_LOCATION'] || '').split(':')
      host = option[0]
      port = option[1]
      if (host && !host.empty?) && (port && !port.empty?)
        { host: host, port: Integer(port) }
      else
        { sock: NullSocket.new }
      end
    end
  @excluded_paths = (ENV['AWS_XRAY_EXCLUDED_PATHS'] || '').split(',')
  @version = VersionDetector.new.call
  @default_annotation = DEFAULT_ANNOTATION
  @default_metadata = DEFAULT_METADATA
  @segment_sending_error_handler = DefaultErrorHandler.new($stderr)
  @worker = Aws::Xray::Worker::Configuration.new
  @sampling_rate = Float(ENV['AWS_XRAY_SAMPLING_RATE'] || 1.0)
  @solr_hook_name = 'solr'
  @record_caller_of_http_requests = false
end

Public Instance Methods

default_annotation=(annotation) click to toggle source

@param [Hash] annotation annotation with key-value format. keys and

values are automatically normalized according to X-Ray's format spec.
# File lib/aws/xray/configuration.rb, line 73
def default_annotation=(annotation)
  @default_annotation = AnnotationNormalizer.call(annotation)
end
version=(v) click to toggle source

@param [String,Proc] version A String or callable object which returns application version.

Default version detection tries to solve with `app_root/REVISION` file.
# File lib/aws/xray/configuration.rb, line 65
def version=(v)
  @version = v.respond_to?(:call) ? v.call : v
end
worker=(conf) click to toggle source

Set given configuration and reset workers according to the given configuration. @param [Aws::Xray::Worker::Configuration] conf

# File lib/aws/xray/configuration.rb, line 89
def worker=(conf)
  @worker = conf
  Aws::Xray::Worker.reset(conf)
  conf
end