def serve
      begin
        @server_transport.listen
        loop do
          client = @server_transport.accept

          remote_address = client.handle.remote_address
          publish :server_connection_opened, remote_address

          trans = @transport_factory.get_transport(client)
          prot = @protocol_factory.get_protocol(trans)

          Thread.new(prot, trans) do |p, t|
            begin
              loop do
                @processor.process(p, p)
              end
            rescue Thrift::TransportException, Thrift::ProtocolException
            ensure
              publish :server_connection_closed, remote_address

              t.close
            end
          end
        end
      ensure
        @server_transport.close
      end
    end
def serve
      begin
        @server_transport.listen
        loop do
          client = @server_transport.accept

          remote_address = client.handle.remote_address
          publish :server_connection_opened, remote_address

          trans = @transport_factory.get_transport(client)
          prot = @protocol_factory.get_protocol(trans)

          Thread.new(prot, trans) do |p, t|
            begin
              loop do
                @processor.process(p, p)
              end
            rescue Thrift::TransportException, Thrift::ProtocolException
            ensure
              publish :server_connection_closed, remote_address

              t.close
            end
          end
        end
      ensure
        @server_transport.close
      end
    end
NOTE: this is a copy of the upstream code with instrumentation added.