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/tracepoints.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, Tracepoints, Tracers

Constant Summary collapse

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

The current version of this gem

'0.0.14'

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#loggerObject

Returns the value of attribute logger.



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

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:



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

def configure
  yield Configuration.instance
end

#disable!Object

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



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

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



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

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

Returns:

  • (Boolean)


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

def enabled?
  !!@enabled
end

#issue_disabled_tracepoints_warningObject

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



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

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.



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

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

#toggle_tracing!Object

Toggles between enabling and disabling tracepoints declared through tracers



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

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