in lib/elastic_apm.rb [270:311]
def with_span(
name,
type = nil,
subtype: nil,
action: nil,
context: nil,
include_stacktrace: true,
trace_context: nil,
parent: nil,
sync: nil
)
unless block_given?
raise ArgumentError,
'expected a block. Do you want `start_span\' instead?'
end
return yield nil unless agent
begin
span =
start_span(
name,
type,
subtype: subtype,
action: action,
context: context,
include_stacktrace: include_stacktrace,
trace_context: trace_context,
parent: parent,
sync: sync
)
result = yield span
span&.outcome ||= Span::Outcome::SUCCESS
result
rescue
span&.outcome ||= Span::Outcome::FAILURE
raise
ensure
end_span
end
end