Skip to content
David Turanski edited this page May 24, 2013 · 18 revisions

Taps

In this section we will show some examples of creating taps on existing streams. Taps are used to monitor incoming messages on existing streams. A tap receives a copy of each message and can process it in a separate flow without affecting the existing stream. A primary use case for taps is capturing metrics such as gauges and counters on existing streams to support real time analytics.

As a prerequisite start the XD Container as instructed in the link:wiki/Getting Started[Getting Started] page.

The Taps covered are

Field Value Counter

A field value counter is a Metric used for counting occurrences of unique values for a named field in a message payload. XD Supports the following payload types out of the box: * POJO (Java bean), * Tuple * JSON String

For example suppose a message source produces a payload with a field named user :

class Foo {
   String user;
   public Foo(String user) {
       this.user = user;
   }
}
---
If the stream source produces messages with the following objects:
   new Foo("fred")
   new Foo("sue")
   new Foo("dave")
   new Foo("sue")
---

The field value counter on the field user will contain:

fred:1, sue:2, dave:1

Multi-value fields are also supported. For example, if a field contains a list, each value will be counted once:

users:["dave","fred","sue"]
users:["sue","jon"]

The field value counter on the field users will contain:

dave:1, fred:1, sue:2, jon:1

Clone this wiki locally