Method: Sentry.with_child_span

Defined in:
lib/sentry-ruby.rb

.with_child_span(**attributes) {|child_span| ... } ⇒ Object

Records the block’s execution as a child of the current span. If the current scope doesn’t have a span, the block would still be executed but the yield param will be nil.

Examples:

Sentry.with_child_span(op: "my operation") do |child_span|
  child_span.set_data(operation_data)
  child_span.set_description(operation_detail)
  # result will be returned
end

Parameters:

  • attributes (Hash)

    attributes for the child span.

Yield Parameters:

  • child_span (Span, nil)

Returns:

  • yield result

[View source]

513
514
515
516
# File 'lib/sentry-ruby.rb', line 513

def with_child_span(**attributes, &block)
  return yield(nil) unless Sentry.initialized?
  get_current_hub.with_child_span(**attributes, &block)
end