Method: TraceView::API::Tracing#trace

Defined in:
lib/traceview/api/tracing.rb

#trace(layer, opts = {}, protect_op = nil) ⇒ Object

Public: Trace a given block of code. Detect any exceptions thrown by the block and report errors.

layer - The layer the block of code belongs to. opts - A hash containing key/value pairs that will be reported along with the first event of this layer (optional). protect_op - specify the operation being traced. Used to avoid double tracing between operations that call each other

Example

def computation(n)
  fib(n)
  raise Exception.new
end

def computation_with_oboe(n)
  trace('fib', { :number => n }) do
    computation(n)
  end
end

result = computation_with_oboe(1000)

Returns the result of the block.



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/traceview/api/tracing.rb', line 34

def trace(layer, opts = {}, protect_op = nil)
  log_entry(layer, opts, protect_op)
  begin
    yield
  rescue Exception => e
    log_exception(layer, e)
    raise
  ensure
    log_exit(layer, {}, protect_op)
  end
end