Class: StackifyRubyAPM::RootInfo Private
- Inherits:
-
Object
- Object
- StackifyRubyAPM::RootInfo
- 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
-
.build(config, transaction) ⇒ Object
private
rubocop:enable Metrics/CyclomaticComplexity rubocop:enable Metrics/PerceivedComplexity.
Instance Method Summary collapse
-
#build ⇒ Object
private
rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/PerceivedComplexity.
-
#initialize(config, transaction) ⇒ RootInfo
constructor
private
A new instance of RootInfo.
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
61 62 63 |
# File 'lib/stackify_apm/root_info.rb', line 61 def self.build(config, transaction) new(config, transaction).build end |
Instance Method Details
#build ⇒ 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: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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/stackify_apm/root_info.rb', line 15 def build # get process id pid = $PID || Process.pid # get hostname and remove extra unwanted characters begin hostname = (@config.hostname || `hostname`).strip rescue StandardError # use socket to get hostname if `hostname` throws exception require 'socket' hostname = Socket.gethostname end hash = { PROFILER_VERSION: StackifyRubyAPM::VERSION, CATEGORY: @transaction.context.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: hostname, 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[:AWS_LAMBDA_ARN] = @transaction.context.aws[:arn] if @transaction.context && @transaction.context.aws && @transaction.context.aws[:arn] hash[:PREFIX_RESPONSE_BODY] = @transaction.context.prefix.response_body.to_s if @transaction.context.prefix && @transaction.context.prefix.response_body hash[:PREFIX_RESPONSE_SIZE_BYTES] = @transaction.context.prefix.response_body.length.to_s if @transaction.context.prefix && @transaction.context.prefix.response_body hash[:PREFIX_RESPONSE_HEADERS] = @transaction.context.prefix.response_headers.to_s if @transaction.context.prefix && @transaction.context.prefix.response_headers hash[:PREFIX_REQUEST_BODY] = @transaction.context.prefix.request_body.to_s if @transaction.context.prefix && @transaction.context.prefix.request_body hash[:PREFIX_REQUEST_SIZE_BYTES] = @transaction.context.prefix.request_body.length.to_s if @transaction.context.prefix && @transaction.context.prefix.request_body hash[:PREFIX_REQUEST_HEADERS] = @transaction.context.prefix.request_headers.to_s if @transaction.context.prefix && @transaction.context.prefix.request_headers hash end |