title: Measure processing throughput in Kafka Streams
body: <p>I have a stream in java built as (anonimized some variables and classes):</p>
  
  <pre><code>    Map&lt;String, Object&gt; props = new HashMap&lt;&gt;();
      Properties config = new Properties();
      config.put(StreamsConfig.APPLICATION_ID_CONFIG, "my-stream-processing-application");
      config.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "my-kafka-broker:6667");
      config.put(StreamsConfig.KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
      config.put(StreamsConfig.VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
  
      KStreamBuilder builder = new KStreamBuilder();
      KStream&lt;String, String&gt; events = builder.stream("my-topic");
  
      events.foreach((key, value) -&gt; {
          CustomClass instance = new CustomClass(value);
          for (AnotherCustomClass anotherInstance: someIterator) {
              anotherInstance(instance);
          }
      });
  
      KafkaStreams streams = new KafkaStreams(builder, config);
      streams.start();
  </code></pre>
  
  <p>for kafka <code>0.10.0.0</code>:</p>
  
  <pre><code>compile group: 'org.apache.kafka', name: 'kafka-streams', version: '0.10.0.0'
  compile group: 'org.apache.kafka', name: 'kafka-clients', version: '0.10.0.0' 
  </code></pre>
  
  <p>My question is the following: </p>
  
  <ul>
  <li>How may I access the <code>KafkaStreams streams.metrics</code> inside the <code>foreach</code> loop? In order to read and / or print the proccesed messages throughput</li>
  <li>More generally: <strong>How may I measure the proceesed messages throughput? Where processed means a message such that</strong> <code>anotherInstance(instance)</code> <strong>has been evaluated</strong></li>
  </ul>