Module: SplunkTracing

Extended by:
SingleForwardable
Defined in:
lib/splunktracing.rb,
lib/splunktracing/span.rb,
lib/splunktracing/scope.rb,
lib/splunktracing/tracer.rb,
lib/splunktracing/version.rb,
lib/splunktracing/reporter.rb,
lib/splunktracing/span_context.rb,
lib/splunktracing/global_tracer.rb,
lib/splunktracing/scope_manager.rb,
lib/splunktracing/transport/nil.rb,
lib/splunktracing/transport/base.rb,
lib/splunktracing/transport/callback.rb,
lib/splunktracing/transport/http_json.rb

Overview

Splunk Tracer

Defined Under Namespace

Modules: Transport Classes: Error, GlobalTracer, Reporter, Scope, ScopeManager, Span, SpanContext, Tracer

Constant Summary collapse

VERSION =
'0.1.0'.freeze

Class Method Summary collapse

Class Method Details

.guidObject

Returns a random guid. Note: this intentionally does not use SecureRandom, which is slower and cryptographically secure randomness is not required here.



30
31
32
33
34
35
36
# File 'lib/splunktracing.rb', line 30

def self.guid
  unless @_lastpid == Process.pid
    @_lastpid = Process.pid
    @_rng = Random.new
  end
  @_rng.bytes(8).unpack('H*')[0]
end

.instanceObject

Returns the singleton instance of the Tracer.



12
13
14
# File 'lib/splunktracing.rb', line 12

def self.instance
  SplunkTracing::GlobalTracer.instance
end

.loggerObject



38
39
40
# File 'lib/splunktracing.rb', line 38

def self.logger
  @logger ||= defined?(::Rails) ? Rails.logger : Logger.new(STDOUT)
end

.logger=(logger) ⇒ Object



42
43
44
# File 'lib/splunktracing.rb', line 42

def self.logger=(logger)
  @logger = logger
end

.micros(time) ⇒ Object

Convert a time to microseconds



24
25
26
# File 'lib/splunktracing.rb', line 24

def self.micros(time)
  (time.to_f * 1E6).floor
end