Sha256: b63ad091713151a83d2d429a3691ed7734155551f4b830ff95631f38f987ba28

Contents?: true

Size: 588 Bytes

Versions: 4

Compression:

Stored size: 588 Bytes

Contents

require 'heimdall_apm/tracked_transaction'

module HeimdallApm
  # Handles the thread-local variable holding the current tracked transaction,
  # populating it the first time it is accessed.
  #
  class TransactionManager
    def self.current
      find || create
    end

    def self.find
      req = Thread.current[:heimdall_request]

      if !req || req.stopped?
        nil
      else
        req
      end
    end

    def self.create
      context = Agent.instance.context
      Thread.current[:heimdall_request] = ::HeimdallApm::TrackedTransaction.new(context)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
heimdall_apm-0.1.3 lib/heimdall_apm/transaction_manager.rb
heimdall_apm-0.1.2 lib/heimdall_apm/transaction_manager.rb
heimdall_apm-0.1.1 lib/heimdall_apm/transaction_manager.rb
heimdall_apm-0.1.0 lib/heimdall_apm/transaction_manager.rb