lib/opentelemetry/trace/tracer.rb in opentelemetry-api-1.0.2 vs lib/opentelemetry/trace/tracer.rb in opentelemetry-api-1.1.0
- old
+ new
@@ -21,13 +21,13 @@
# On exit, the Span that was active before calling this method will be reactivated. If an
# exception occurs during the execution of the provided block, it will be recorded on the
# span and reraised.
# @yield [span, context] yields the newly created span and a context containing the
# span to the block.
- def in_span(name, attributes: nil, links: nil, start_timestamp: nil, kind: nil)
+ def in_span(name, attributes: nil, links: nil, start_timestamp: nil, kind: nil, &block)
span = nil
span = start_span(name, attributes: attributes, links: links, start_timestamp: start_timestamp, kind: kind)
- Trace.with_span(span) { |s, c| yield s, c }
+ Trace.with_span(span, &block)
rescue Exception => e # rubocop:disable Lint/RescueException
span&.record_exception(e)
span&.status = Status.error("Unhandled exception of type: #{e.class}")
raise e
ensure