global

def write_body(version, body, head = false, trailer = nil)

def write_body(version, body, head = false, trailer = nil)
	attributes = {
		version: version,
		head: head,
		trailer: trailer,
		body: body&.as_json,
	}
	
	Traces.trace("protocol.http1.connection.write_body", attributes: attributes) do |span|
		super
	rescue => error
		# Capture the body state at the time of the error for EPIPE debugging:
		span["error.body"] = body&.as_json
		span["error.connection"] = {
			state: @state,
			persistent: @persistent,
			count: @count,
			stream_closed: @stream.nil?
		}
		
		raise error
	end
end