Class: StackifyRubyAPM::RootInfo Private

Inherits:
Object
  • Object
show all
Defined in:
lib/stackify_apm/root_info.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, transaction) ⇒ RootInfo

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of RootInfo.



8
9
10
11
# File 'lib/stackify_apm/root_info.rb', line 8

def initialize(config, transaction)
  @transaction = transaction
  @config = config
end

Class Method Details

.build(config, transaction) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

rubocop:enable Metrics/CyclomaticComplexity rubocop:enable Metrics/PerceivedComplexity



44
45
46
# File 'lib/stackify_apm/root_info.rb', line 44

def self.build(config, transaction)
  new(config, transaction).build
end

Instance Method Details

#buildObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/PerceivedComplexity



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
# File 'lib/stackify_apm/root_info.rb', line 15

def build
  # get process id
  pid = $PID || Process.pid
  hash = {
    CATEGORY: 'Ruby',
    APPLICATION_PATH: '/',
    APPLICATION_FILESYSTEM_PATH: @config.root_path,
    APPLICATION_NAME: @config.application_name.strip,
    APPLICATION_ENV: @config.environment_name || 'Development',
    REPORTING_URL: @transaction.name,
    TRACE_ID: @transaction.id,
    THREAD_ID: Thread.current.object_id,
    TRACE_SOURCE: 'RUBY',
    TRACE_TARGET: 'RETRACE',
    HOST_NAME: (@config.hostname || `hostname`).strip,
    OS_TYPE: StackifyRubyAPM::Util.host_os,
    PROCESS_ID: pid,
    TRACE_VERSION: '2.0',
    TRACETYPE: @transaction.type || 'WEBAPP'
  }
  hash[:METHOD] = @transaction.context.request.method if @transaction.context && @transaction.context.request && @transaction.context.request.method
  hash[:STATUS] = @transaction.context.response.status_code if @transaction.context && @transaction.context.response && @transaction.context.response.status_code
  hash[:URL] = @transaction.context.request.url[:full] if @transaction.context && @transaction.context.request && @transaction.context.request.url[:full]
  hash[:RUM] = true if @config.rum_enabled.is_a?(TrueClass)
  hash
end