Module: Oboe::API::Profiling
- Defined in:
- lib/oboe/api/profiling.rb
Instance Method Summary collapse
-
#profile(profile_name, report_kvs = {}, with_backtrace = false) ⇒ Object
Public: Profile a given block of code.
Instance Method Details
#profile(profile_name, report_kvs = {}, with_backtrace = false) ⇒ Object
Public: Profile a given block of code. Detect any exceptions thrown by the block and report errors.
profile_name - A name used to identify the block being profiled. report_kvs - A hash containing key/value pairs that will be reported along
with the event of this profile (optional).
with_backtrace - Boolean to indicate whether a backtrace should
be collected with this trace event.
Example
def computation(n)
Oboe::API.profile('fib', { :n => n }) do
fib(n)
end
end
Returns the result of the block.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/oboe/api/profiling.rb', line 27 def profile(profile_name, report_kvs={}, with_backtrace=false) report_kvs[:Language] ||= :ruby report_kvs[:ProfileName] ||= profile_name Oboe::Context.log(nil, 'profile_entry', report_kvs, with_backtrace) begin yield rescue Exception => e log_exception(nil, e) raise ensure exit_kvs = {} exit_kvs[:Language] = :ruby exit_kvs[:ProfileName] = report_kvs[:ProfileName] Oboe::Context.log(nil, 'profile_exit', exit_kvs, false) end end |