Description
Java's Stream provides a handy peek method that observes elements in the stream without transforming or filtering them. While you can emulate this functionality with either a filter or map, peek provides potentially useful semantic information (doesn't modify the stream) and is much more concise.
Example usage: using Dropwizard Metrics to provide event counters
KStream<Integer, String> s = ...; s.map(this::mungeData) .peek((i, s) -> metrics.noteMungedEvent(i, s)) .filter(this::hadProcessingError) .print();
Attachments
Issue Links
- relates to
-
KAFKA-4772 Exploit #peek to implement #print() and other methods
-
- Resolved
-
- links to
- mentioned in
-
Page Loading...