Class: StaticTracing::Tracepoint

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

Defined Under Namespace

Classes: InvalidArgType, InvalidArgumentError, TracepointMissingError

Constant Summary collapse

VALID_ARGS_TYPES =
[Integer, String].freeze

Instance Attribute Summary collapse

Class Method 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.



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/ruby-static-tracing/tracepoint.rb', line 36

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.



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

def args
  @args
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#provider_nameObject (readonly)

Returns the value of attribute provider_name.



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

def provider_name
  @provider_name
end

Class Method Details

.fetch(provider, name) ⇒ Object

Gets a trace instance by provider name and name



9
10
11
12
13
# File 'lib/ruby-static-tracing/tracepoint.rb', line 9

def fetch(provider, name)
  Provider.fetch(provider).tracepoints.fetch(name.to_s) do
    raise TracepointMissingError
  end
end

Instance Method Details

#enabled?Boolean

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

Returns:

  • (Boolean)


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

def enabled?; end

#fire(*values) ⇒ Object

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



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

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

The provider this tracepoint is defined on



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

def provider
  Provider.fetch(@provider_name)
end