Module: OrangeTap

Defined in:
lib/orange_tap.rb,
lib/orange_tap/event.rb,
lib/orange_tap/config.rb,
lib/orange_tap/worker.rb,
lib/orange_tap/session.rb,
lib/orange_tap/version.rb,
lib/orange_tap/pending_span.rb,
lib/orange_tap/builtin_filter.rb,
lib/orange_tap/otel_converter.rb,
lib/orange_tap/method_registry.rb,
sig/orange_tap.rbs

Defined Under Namespace

Modules: OtelConverter Classes: AlreadyOpenError, BuiltinFilter, Config, Error, Event, MethodRegistry, NotOpenError, PendingSpan, Session, UntraceableMethodError, Worker

Constant Summary collapse

VERSION =

Returns:

  • (String)
"0.1.1"

Class Method Summary collapse

Class Method Details

.configObject



31
32
33
# File 'lib/orange_tap.rb', line 31

def config
  @config ||= Config.new
end

.default_registryObject



27
28
29
# File 'lib/orange_tap.rb', line 27

def default_registry
  @default_registry ||= MethodRegistry.new
end

.new(**opts) ⇒ Object

OrangeTap.new -> Session, so tape = OrangeTap.new; tape.open; ...; tape.stop reads like constructing a recorder, while OrangeTap itself stays a module.



23
24
25
# File 'lib/orange_tap.rb', line 23

def new(**opts)
  Session.new(**opts)
end

.open(name = nil, &block) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/orange_tap.rb', line 50

def open(name = nil, &block)
  tape = new
  tape.open(name)
  return tape unless block

  begin
    block.call
    tape.stop
  rescue Exception # rubocop:disable Lint/RescueException
    # Make sure TracePoints are disabled and the worker is drained even
    # when the block raises. The output path is unrecoverable here, so we
    # re-raise the original error instead of returning it.
    begin
      tape.stop
    rescue StandardError
      nil
    end
    raise
  end
end

.trace_all_instance_methods(klass) ⇒ Object



46
47
48
# File 'lib/orange_tap.rb', line 46

def trace_all_instance_methods(klass)
  default_registry.register_all_instance_methods(klass)
end

.trace_method(*method_objs) ⇒ Object

Accepts one or more Method/UnboundMethod objects, or notation strings ("Foo.bar" for a class/singleton method, "Foo#bar" for an instance method), and registers them all in a single call.



38
39
40
# File 'lib/orange_tap.rb', line 38

def trace_method(*method_objs)
  default_registry.register(*method_objs)
end

.untrace_method(*method_objs) ⇒ Object



42
43
44
# File 'lib/orange_tap.rb', line 42

def untrace_method(*method_objs)
  default_registry.unregister(*method_objs)
end