Method: Honeycomb::Client#start_span

Defined in:
lib/honeycomb/client.rb

#start_span(name:, serialized_trace: nil, **fields) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/honeycomb/client.rb', line 53

def start_span(name:, serialized_trace: nil, **fields)
  current_span = new_span_for_context(serialized_trace: serialized_trace)

  fields.each do |key, value|
    current_span.add_field(key, value)
  end

  current_span.add_field("name", name)

  return current_span unless block_given?

  begin
    yield current_span
  rescue StandardError => e
    add_exception_data(current_span, e)

    raise e
  ensure
    current_span.send
  end
end