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_HOST =
option ? option.split(':').first : nil
DEFAULT_PORT =
option ? Integer(option.split(':').last) : nil
DEFAULT_NAME =
name_option ? name_option : nil
DEFAULT_EXCLUDED_PATHS =
path_option ? path_option.split(',') : []
DEFAULT_ANNOTATION =
{
  hostname: Socket.gethostname,
}.freeze
DEFAULT_METADATA =
{
  tracing_sdk: {
    name: 'aws-xray',
    version: Aws::Xray::VERSION,
  }
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#client_optionsHash

Returns client_options For xray-agent client.

  • host: e.g. ‘127.0.0.1’

  • port: e.g. 2000.

Returns:

  • (Hash)

    client_options For xray-agent client.

    • host: e.g. ‘127.0.0.1’

    • port: e.g. 2000



28
29
30
31
32
33
34
35
# File 'lib/aws/xray/configuration.rb', line 28

def client_options
  @client_options ||=
    if DEFAULT_HOST && DEFAULT_PORT
      { host: DEFAULT_HOST, port: DEFAULT_PORT }
    else
      { sock: NullSocket.new }
    end
end

#default_metadataHash

Returns Default metadata.

Returns:

  • (Hash)

    Default metadata.



73
74
75
# File 'lib/aws/xray/configuration.rb', line 73

def 
   ||= 
end

#excluded_pathsArray<String>

Returns:

  • (Array<String>)


39
40
41
# File 'lib/aws/xray/configuration.rb', line 39

def excluded_paths
  @excluded_paths ||= DEFAULT_EXCLUDED_PATHS
end

#nameString

Returns name Logical service name for this application.

Returns:

  • (String)

    name Logical service name for this application.



20
21
22
# File 'lib/aws/xray/configuration.rb', line 20

def name
  @name ||= DEFAULT_NAME
end

Instance Method Details

#default_annotationHash

Returns default annotation with key-value format.

Returns:

  • (Hash)

    default annotation with key-value format.



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

def default_annotation
  @default_annotation ||= DEFAULT_ANNOTATION
end

#default_annotation=(annotation) ⇒ Object

Parameters:

  • h (Hash)

    default annotation Hash.



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

def default_annotation=(annotation)
  @default_annotation = AnnotationNormalizer.call(annotation)
end

#versionString

Returns:

  • (String)


45
46
47
# File 'lib/aws/xray/configuration.rb', line 45

def version
  @version ||= VersionDetector.new.call
end

#version=(v) ⇒ Object

Parameters:

  • version (String, Proc)

    A String or callable object which returns application version. Default version detection tries to solve with ‘app_root/REVISION` file.



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

def version=(v)
  @version = v.respond_to?(:call) ? v.call : v
end