Sha256: 6fcc2dd2c98cae07725c6194cedac8177b0bdd8e0df01e6c1968e4a215840c3a

Contents?: true

Size: 1.47 KB

Versions: 3

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::Agent.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

3 entries across 3 versions & 1 rubygems

Version Path
oneapm_rpm-1.1.2 lib/one_apm/collector/commands/xray_session.rb
oneapm_rpm-1.1.1 lib/one_apm/collector/commands/xray_session.rb
oneapm_rpm-1.1.0 lib/one_apm/collector/commands/xray_session.rb