Module: StaticTracing

Extended by:
StaticTracing
Included in:
StaticTracing
Defined in:
lib/ruby-static-tracing.rb,
lib/ruby-static-tracing/tracers.rb,
lib/ruby-static-tracing/version.rb,
lib/ruby-static-tracing/platform.rb,
lib/ruby-static-tracing/provider.rb,
lib/ruby-static-tracing/tracepoint.rb,
lib/ruby-static-tracing/tracer/base.rb,
lib/ruby-static-tracing/tracer/stack.rb,
lib/ruby-static-tracing/configuration.rb,
lib/ruby-static-tracing/tracer/helpers.rb,
lib/ruby-static-tracing/tracer/latency.rb,
lib/ruby-static-tracing/tracer/concerns/latency_tracer.rb

Overview

FIXME: Including StaticTracing should cause every method in a module or class to be registered Implement this by introspecting all methods on the includor, and wrapping them.

Defined Under Namespace

Modules: Platform, Tracer Classes: Configuration, InternalError, Provider, SyscallError, Tracepoint, Tracers

Constant Summary collapse

BaseError =
Class.new(StandardError)
USDTError =
Class.new(BaseError)
VERSION =

The current version of this gem

'0.0.15'

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#loggerObject

Returns the value of attribute logger.



22
23
24
# File 'lib/ruby-static-tracing.rb', line 22

def logger
  @logger
end

Instance Method Details

#configure {|Configuration.instance| ... } ⇒ Object

Block to configure static tracing, eg:

StaticTracing.configure do |config|
  config.add_tracer(StaticTracing::Tracer::Latency)
end

Yields:



73
74
75
# File 'lib/ruby-static-tracing.rb', line 73

def configure
  yield Configuration.instance
end

#disable!Object

Overwrite the definition of all functions to their original definition, no longer wrapping them



57
58
59
60
61
# File 'lib/ruby-static-tracing.rb', line 57

def disable!
  StaticTracing::Tracers.disable!
  StaticTracing::Provider.disable! # FIXME dangerous
  @enabled = false
end

#enable!Object

Overwrite the definition of all functions that are enabled with a wrapped version that has tracing enabled



49
50
51
52
53
# File 'lib/ruby-static-tracing.rb', line 49

def enable!
  StaticTracing::Tracers.enable!
  StaticTracing::Provider.enable! # FIXME individually call enable
  @enabled = true
end

#enabled?Boolean

Should indicate if static tracing is enabled - a global constant



43
44
45
# File 'lib/ruby-static-tracing.rb', line 43

def enabled?
  !!@enabled
end

#issue_disabled_tracepoints_warningObject

This will print a message indicating that tracepoints are disabled on this platform



27
28
29
30
31
32
# File 'lib/ruby-static-tracing.rb', line 27

def issue_disabled_tracepoints_warning
  return if defined?(@warning_issued)

  @warning_issued = true
  logger.info("USDT tracepoints are not presently supported supported on #{RUBY_PLATFORM} - all operations will no-op")
end

#nsecObject

Efficiently return the current monotonic clocktime. Wraps libc clock_gettime The overhead of this is tested to be on the order of 10 microseconds under normal conditions You should inline this method in your tracer to avoid an extra method call.



38
39
40
# File 'lib/ruby-static-tracing.rb', line 38

def nsec
  Process.clock_gettime(Process::CLOCK_MONOTONIC, :nanosecond)
end

#toggle_tracing!Object

Toggles between enabling and disabling tracepoints declared through tracers



64
65
66
# File 'lib/ruby-static-tracing.rb', line 64

def toggle_tracing!
  enabled? ? disable! : enable!
end