Module: StaticTracing

Extended by:
StaticTracing
Included in:
StaticTracing
Defined in:
lib/ruby-static-tracing.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/configuration.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 Classes: Configuration, InternalError, Provider, SyscallError, Tracepoint

Constant Summary collapse

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

The current version of this gem

'0.0.17'

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#loggerObject

Returns the value of attribute logger.



19
20
21
# File 'lib/ruby-static-tracing.rb', line 19

def logger
  @logger
end

Instance Method Details

#disable!Object

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



53
54
55
56
# File 'lib/ruby-static-tracing.rb', line 53

def 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



46
47
48
49
# File 'lib/ruby-static-tracing.rb', line 46

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

#enabled?Boolean

Should indicate if static tracing is enabled - a global constant



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

def enabled?
  !!@enabled
end

#issue_disabled_tracepoints_warningObject

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



24
25
26
27
28
29
# File 'lib/ruby-static-tracing.rb', line 24

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.



35
36
37
# File 'lib/ruby-static-tracing.rb', line 35

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

#toggle_tracing!Object

Toggles between enabling and disabling tracepoints declared through tracers



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

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