Sha256: 07664f8b975dac41f28effce4f92be01ad9b982d2dd9f1bba73295a163270f30

Contents?: true

Size: 1.47 KB

Versions: 39

Compression:

Stored size: 1.47 KB

Contents

# encoding: utf-8

require 'forwardable'

module OneApm
  module Collector
    module Commands
      class XraySession
        extend Forwardable

        attr_reader :id, :command_arguments
        attr_reader :xray_session_name, :key_transaction_name,
                    :requested_trace_count, :duration, :sample_period

        def initialize(command_arguments)
          @command_arguments     = command_arguments
          @id                    = command_arguments.fetch("x_ray_id", nil)
          @xray_session_name     = command_arguments.fetch("xray_session_name", "")
          @key_transaction_name  = command_arguments.fetch("key_transaction_name", "")
          @requested_trace_count = command_arguments.fetch("requested_trace_count", 100)
          @duration              = command_arguments.fetch("duration", 86400)
          @sample_period         = command_arguments.fetch("sample_period", 0.1)
          @run_profiler          = command_arguments.fetch("run_profiler", true)
        end

        def active?
          @active
        end

        def run_profiler?
          @run_profiler && OneApm::Manager.config[:'xray_session.allow_profiles']
        end

        def activate
          @active = true
          @start_time = Time.now
        end

        def deactivate
          @active = false
        end

        def requested_period
          @sample_period
        end

        def finished?
          @start_time + @duration < Time.now
        end
      end
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
oneapm_rpm-1.4.2 lib/one_apm/collector/commands/xray_session.rb
oneapm_rpm-1.4.1 lib/one_apm/collector/commands/xray_session.rb
oneapm_rpm-1.4.0 lib/one_apm/collector/commands/xray_session.rb
oneapm_rpm-1.3.7 lib/one_apm/collector/commands/xray_session.rb
oneapm_rpm-1.3.7.rc1 lib/one_apm/collector/commands/xray_session.rb
oneapm_rpm-1.3.6 lib/one_apm/collector/commands/xray_session.rb
oneapm_rpm-1.3.6.rc1 lib/one_apm/collector/commands/xray_session.rb
oneapm_rpm-1.3.5 lib/one_apm/collector/commands/xray_session.rb
oneapm_rpm-1.3.5.rc1 lib/one_apm/collector/commands/xray_session.rb
oneapm_rpm-1.3.4 lib/one_apm/collector/commands/xray_session.rb
oneapm_rpm-1.3.4.rc1 lib/one_apm/collector/commands/xray_session.rb
oneapm_rpm-1.3.3 lib/one_apm/collector/commands/xray_session.rb
oneapm_rpm-1.3.3.rc1 lib/one_apm/collector/commands/xray_session.rb
oneapm_rpm-1.3.2 lib/one_apm/collector/commands/xray_session.rb
oneapm_rpm-1.3.2.rc1 lib/one_apm/collector/commands/xray_session.rb
oneapm_rpm-1.3.1 lib/one_apm/collector/commands/xray_session.rb
oneapm_rpm-1.3.1.rc1 lib/one_apm/collector/commands/xray_session.rb
oneapm_rpm-1.3.0 lib/one_apm/collector/commands/xray_session.rb
oneapm_rpm-1.3.0.rc1 lib/one_apm/collector/commands/xray_session.rb
oneapm_rpm-1.2.9 lib/one_apm/collector/commands/xray_session.rb