Class: StaticTracing::Tracepoint

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-static-tracing/tracepoint.rb

Defined Under Namespace

Classes: InvalidArgType, InvalidArgumentError

Constant Summary collapse

VALID_ARGS_TYPES =
[Integer, String].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(provider_name, name, *args) ⇒ Tracepoint

Creates a new tracepoint. If a provider by the name specified doesn’t exist already, one will be added implicitly.



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/ruby-static-tracing/tracepoint.rb', line 25

def initialize(provider_name, name, *args)
  @provider_name = provider_name
  @name = name
  validate_args(args)
  @args = args

  if StaticTracing::Platform.supported_platform?
    tracepoint_initialize(provider_name, name, args)
    provider.add_tracepoint(self)
  else
    StaticTracing.issue_disabled_tracepoints_warning
  end
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



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

def args
  @args
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#provider_nameObject (readonly)

Returns the value of attribute provider_name.



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

def provider_name
  @provider_name
end

Instance Method Details

#enabled?Boolean

Returns true if a tracepoint is currently attached to, indicating we should fire it

Returns:

  • (Boolean)


54
# File 'lib/ruby-static-tracing/tracepoint.rb', line 54

def enabled?; end

#fire(*values) ⇒ Object

Fire a tracepoint, sending the data off to be received by a tracing program like dtrace



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

def fire(*values)
  values.each_with_index do |arg, i|
    raise InvalidArgumentError.new(arg, args[i]) unless arg.is_a?(args[i])
  end
  _fire_tracepoint(values)
end

#providerObject



48
49
50
# File 'lib/ruby-static-tracing/tracepoint.rb', line 48

def provider
  Provider.fetch(@provider_name)
end