Method: Sentry::Span#with_child_span

Defined in:
lib/sentry/span.rb

#with_child_span(**attributes, &block) {|child_span| ... } ⇒ Object

Starts a child span, yield it to the given block, and then finish the span after the block is executed.

Examples:

span.with_child_span do |child_span|
  # things happen here will be recorded in a child span
end

Parameters:

  • attributes (Hash)

    the attributes for the child span.

  • block (Proc)

    the action to be recorded in the child span.

Yield Parameters:

[View source]

234
235
236
237
238
239
240
241
242
243
244
# File 'lib/sentry/span.rb', line 234

def with_child_span(**attributes, &block)
  child_span = start_child(**attributes)

  yield(child_span)

  child_span.finish
rescue
  child_span.set_http_status(500)
  child_span.finish
  raise
end