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

#initialize ⇒ Configuration

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
45
# 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

Instance Attribute Details

#client_options ⇒ Hash

Parameters:

  • client_options (Hash) —

    For xray-agent client.

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

Returns:

  • (Hash)


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

def client_options
  @client_options
end

#default_annotation ⇒ Hash

Returns:

  • (Hash)


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

def default_annotation
  @default_annotation
end

#default_metadata ⇒ Hash

Parameters:

  • default_metadatametadata (Hash) —

    Default metadata.

Returns:

  • (Hash)


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

def 
  @default_metadata
end

#excluded_paths ⇒ Array<String>

Parameters:

  • excluded_paths (Array<String>)

Returns:

  • (Array<String>)


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

def excluded_paths
  @excluded_paths
end

#logger ⇒ Logger

Parameters:

  • logger (Logger)

Returns:

  • (Logger)


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

def logger
  @logger
end

#name ⇒ String

Parameters:

  • name (String) —

    Logical service name for this application.

Returns:

  • (String)


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

def name
  @name
end

#record_caller_of_http_requests ⇒ Boolean

Parameters:

  • record_caller_of_http_requests (Boolean)

Returns:

  • (Boolean)


110
111
112
# File 'lib/aws/xray/configuration.rb', line 110

def record_caller_of_http_requests
  @record_caller_of_http_requests
end

#sampling_rate ⇒ Float

Default is undefined.

Parameters:

  • sampling_rate (Float)

Returns:

  • (Float)


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

def sampling_rate
  @sampling_rate
end

#segment_sending_error_handler ⇒ Object

Parameters:

  • segment_sending_error_handler (Proc) —

    Callable object



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

def segment_sending_error_handler
  @segment_sending_error_handler
end

#solr_hook_name ⇒ String

Parameters:

  • solr_hook_name (String)

Returns:

  • (String)


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

def solr_hook_name
  @solr_hook_name
end

#version ⇒ String

Returns:

  • (String)


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

def version
  @version
end

#worker ⇒ Aws::Xray::Worker::Configuration



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

def worker
  @worker
end