2016-10-27 23:13:14 +03:00
|
|
|
require 'forwardable'
|
2017-02-07 07:52:06 +03:00
|
|
|
require 'logger'
|
2016-04-05 04:07:08 +03:00
|
|
|
|
2016-10-29 00:09:47 +03:00
|
|
|
# LightStep Tracer
|
2016-04-05 04:07:08 +03:00
|
|
|
module LightStep
|
2016-10-27 23:13:14 +03:00
|
|
|
extend SingleForwardable
|
2016-04-19 02:13:31 +03:00
|
|
|
|
2016-10-29 00:09:47 +03:00
|
|
|
# Base class for all LightStep errors
|
2016-10-28 19:35:20 +03:00
|
|
|
class Error < StandardError; end
|
|
|
|
|
2016-04-19 02:13:31 +03:00
|
|
|
# Returns the singleton instance of the Tracer.
|
|
|
|
def self.instance
|
2016-10-27 18:46:04 +03:00
|
|
|
LightStep::GlobalTracer.instance
|
|
|
|
end
|
2016-04-19 02:13:31 +03:00
|
|
|
|
2016-10-27 23:13:14 +03:00
|
|
|
def_delegator :instance, :configure
|
|
|
|
def_delegator :instance, :start_span
|
2019-03-06 19:00:31 +03:00
|
|
|
def_delegator :instance, :start_active_span
|
2019-08-27 21:18:43 +03:00
|
|
|
def_delegator :instance, :active_span
|
2016-10-27 23:13:14 +03:00
|
|
|
def_delegator :instance, :disable
|
|
|
|
def_delegator :instance, :enable
|
|
|
|
def_delegator :instance, :flush
|
2016-10-31 22:33:55 +03:00
|
|
|
|
|
|
|
# Convert a time to microseconds
|
|
|
|
def self.micros(time)
|
|
|
|
(time.to_f * 1E6).floor
|
|
|
|
end
|
2016-10-31 22:52:48 +03:00
|
|
|
|
|
|
|
# Returns a random guid. Note: this intentionally does not use SecureRandom,
|
|
|
|
# which is slower and cryptographically secure randomness is not required here.
|
|
|
|
def self.guid
|
2016-12-14 17:39:29 +03:00
|
|
|
unless @_lastpid == Process.pid
|
2016-12-14 17:39:00 +03:00
|
|
|
@_lastpid = Process.pid
|
2016-12-13 23:55:54 +03:00
|
|
|
@_rng = Random.new
|
|
|
|
end
|
2016-10-31 22:52:48 +03:00
|
|
|
@_rng.bytes(8).unpack('H*')[0]
|
|
|
|
end
|
2017-02-07 07:52:06 +03:00
|
|
|
|
|
|
|
def self.logger
|
|
|
|
@logger ||= defined?(::Rails) ? Rails.logger : Logger.new(STDOUT)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.logger=(logger)
|
|
|
|
@logger = logger
|
|
|
|
end
|
2016-04-05 04:07:08 +03:00
|
|
|
end
|
2016-10-28 19:35:20 +03:00
|
|
|
|
2016-10-31 20:38:31 +03:00
|
|
|
require 'lightstep/tracer'
|
|
|
|
require 'lightstep/global_tracer'
|
2018-10-18 18:07:24 +03:00
|
|
|
require 'lightstep/scope'
|
|
|
|
require 'lightstep/scope_manager'
|