module StaticTracing

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.

Constants

BaseError
InternalError
USDTError
VERSION

The current version of this gem

Attributes

logger[RW]

Public Instance Methods

configure() { |instance| ... } click to toggle source

Block to configure static tracing, eg:

StaticTracing.configure do |config|
  config.add_tracer(StaticTracing::Tracer::Latency)
end
# File lib/ruby-static-tracing.rb, line 72
def configure
  yield Configuration.instance
end
disable!() click to toggle source

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

# File lib/ruby-static-tracing.rb, line 56
def disable!
  StaticTracing::Tracers.disable!
  StaticTracing::Provider.disable! # FIXME dangerous
  @enabled = false
end
enable!() click to toggle source

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

# File lib/ruby-static-tracing.rb, line 48
def enable!
  StaticTracing::Tracers.enable!
  StaticTracing::Provider.enable! # FIXME individually call enable
  @enabled = true
end
enabled?() click to toggle source

Should indicate if static tracing is enabled - a global constant

# File lib/ruby-static-tracing.rb, line 42
def enabled?
  !!@enabled
end
issue_disabled_tracepoints_warning() click to toggle source

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

# File lib/ruby-static-tracing.rb, line 26
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
nsec() click to toggle source

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.

# File lib/ruby-static-tracing.rb, line 37
def nsec
  Process.clock_gettime(Process::CLOCK_MONOTONIC, :nanosecond)
end
toggle_tracing!() click to toggle source

Toggles between enabling and disabling tracepoints declared through tracers

# File lib/ruby-static-tracing.rb, line 63
def toggle_tracing!
  enabled? ? disable! : enable!
end