anchor.diff:              {ok, State}
       end;
   
  -dispatch_info(metrics_batch_finished, State = #state{currently_selected_bench = Id, current_transmission_guid = Guid}) ->
  +dispatch_info({metrics_batch_finished, Id, Guid}, State = #state{currently_selected_bench = Id, current_transmission_guid = Guid}) ->
       {reply, #{type => "METRICS_BATCH_FINISHED", bench => Id, guid => Guid}, State};
   
  -dispatch_info({transmit_metrics, BenchId, Values}, State = #state{currently_selected_bench = Id, current_transmission_guid = Guid}) ->
  -    case Id of
  -        BenchId ->
  -            Event = #{type => "METRICS_UPDATE", bench => BenchId, guid => Guid, data => erlang:list_to_binary(Values)},
  -            {reply, Event, State};
  -        _ ->
  -            {ok, State}
  -    end;
  +dispatch_info({metrics_batch_finished, _Id, _Guid}, State = #state{}) ->
  +    {ok, State};
  +
  +dispatch_info({transmit_metrics, Id, Guid, Values}, State = #state{currently_selected_bench = Id, current_transmission_guid = Guid}) ->
  +    Event = #{type => "METRICS_UPDATE", bench => Id, guid => Guid, data => erlang:list_to_binary(Values)},
  +    {reply, Event, State};
  +
  +dispatch_info({transmit_metrics, _Id, _Guid, _Values}, State = #state{}) ->
  +    {ok, State};
   
   dispatch_info({notify, Severity, Msg}, State) ->
       Event = #{type => "NOTIFY",
  
positive.code:     stop_reading_metrics(MetricsReaderRef),
      #{<<"bench">> := Id, <<"guid">> := Guid} = Cmd,
      Self = self(),
      BatchFinishedFun = fun () -> Self ! metrics_batch_finished end,
      SendMetricsFun = fun (Values) -> Self ! {transmit_metrics, Id, Values} end,
      NewMetricsReaderRef = start_reading_metrics(Id, SendMetricsFun, BatchFinishedFun),
      {ok, State#state{currently_selected_bench = Id, current_transmission_guid = Guid, metrics_reader_ref = NewMetricsReaderRef}};
  
  
negative.code:     end.
  
  perform_reading(BenchId, FileReader, SendFun, BatchFinishedFun, Timeout) ->
      perform_reading(BenchId, FileReader, SendFun, BatchFinishedFun, Timeout, [], 0).
  perform_reading(BenchId, FileReader, SendFun, BatchFinishedFun, Timeout, Buffer, LinesRead) ->
      case FileReader(read_line) of
          {ok, Data} when LinesRead > 500 ->
              Buf = [Data|Buffer],
              SendFun(lists:reverse(Buf)),
              perform_reading(BenchId, FileReader, SendFun, BatchFinishedFun, Timeout, [], 0);
          {ok, Data} ->
              perform_reading(BenchId, FileReader, SendFun, BatchFinishedFun, Timeout, [Data|Buffer], LinesRead + 1);
          eof ->
              case Buffer of
                  [] -> ok;
                  _ -> SendFun(lists:reverse(Buffer))
              end,
              BatchFinishedFun(),
              case mzb_api_server:is_datastream_ended(BenchId) of
                  true  -> ok;
                  false ->
                      timer:sleep(Timeout),
                      perform_reading(BenchId, FileReader, SendFun, BatchFinishedFun, Timeout, [], 0)
              end;
          {error, Reason} ->
              case Buffer of
                  [] -> ok;
                  _ -> SendFun(lists:reverse(Buffer))
              end,
              erlang:error(Reason)
      end.
  