lightstep-tracer-ruby/lib/lightstep.rb

52 строки
1.2 KiB
Ruby
Исходник Постоянная ссылка Обычный вид История

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
class Error < StandardError; end
2016-04-19 02:13:31 +03:00
# Returns the singleton instance of the Tracer.
def self.instance
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
def_delegator :instance, :start_active_span
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
unless @_lastpid == Process.pid
@_lastpid = Process.pid
@_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-31 20:38:31 +03:00
require 'lightstep/tracer'
require 'lightstep/global_tracer'
require 'lightstep/scope'
require 'lightstep/scope_manager'