Class: Aws::Xray::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/aws/xray/configuration.rb

Overview

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

Constant Summary collapse

DEFAULT_ANNOTATION =

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

{
  hostname: Socket.gethostname,
}.freeze
DEFAULT_METADATA =
{
  tracing_sdk: {
    name: 'aws-xray',
    version: Aws::Xray::VERSION,
  }
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# 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'] || 0.001)
  @solr_hook_name = 'solr'
end

Instance Attribute Details

#client_optionsHash

Parameters:

  • client_options (Hash)

    For xray-agent client.

    • host: e.g. ‘127.0.0.1’

    • port: e.g. 2000

Returns:

  • (Hash)


54
55
56
# File 'lib/aws/xray/configuration.rb', line 54

def client_options
  @client_options
end

#default_annotationHash

Returns:

  • (Hash)


69
70
71
# File 'lib/aws/xray/configuration.rb', line 69

def default_annotation
  @default_annotation
end

#default_metadataHash

Parameters:

  • default_metadatametadata (Hash)

    Default metadata.

Returns:

  • (Hash)


78
79
80
# File 'lib/aws/xray/configuration.rb', line 78

def 
  @default_metadata
end

#excluded_pathsArray<String>

Parameters:

  • excluded_paths (Array<String>)

Returns:

  • (Array<String>)


58
59
60
# File 'lib/aws/xray/configuration.rb', line 58

def excluded_paths
  @excluded_paths
end

#loggerLogger

Parameters:

  • logger (Logger)

Returns:

  • (Logger)


101
102
103
# File 'lib/aws/xray/configuration.rb', line 101

def logger
  @logger
end

#nameString

Parameters:

  • name (String)

    Logical service name for this application.

Returns:

  • (String)


48
49
50
# File 'lib/aws/xray/configuration.rb', line 48

def name
  @name
end

#sampling_rateFloat

Default is 0.1%.

Parameters:

  • sampling_rate (Float)

Returns:

  • (Float)


97
98
99
# File 'lib/aws/xray/configuration.rb', line 97

def sampling_rate
  @sampling_rate
end

#segment_sending_error_handlerObject

Parameters:

  • segment_sending_error_handler (Proc)

    Callable object



81
82
83
# File 'lib/aws/xray/configuration.rb', line 81

def segment_sending_error_handler
  @segment_sending_error_handler
end

#solr_hook_nameString

Parameters:

  • solr_hook_name (String)

Returns:

  • (String)


105
106
107
# File 'lib/aws/xray/configuration.rb', line 105

def solr_hook_name
  @solr_hook_name
end

#versionString

Returns:

  • (String)


61
62
63
# File 'lib/aws/xray/configuration.rb', line 61

def version
  @version
end

#workerAws::Xray::Worker::Configuration



84
85
86
# File 'lib/aws/xray/configuration.rb', line 84

def worker
  @worker
end