de.is24.util.monitoring.helper
Class HistogramLikeValue

java.lang.Object
  extended by de.is24.util.monitoring.helper.HistogramLikeValue

public class HistogramLikeValue
extends Object

Convenience class that makes it easier to log values in a histogram-like fashion. Values are automatically grouped into ranges/"bins" of similar values; the width of the "bins" into which values are grouped can be specified by the constructor parameter "factor". New values are divided by the given factor in order to determine the bin in which the value should be counted, e.g. if you construct a HistogramLikeValue with a factor of "1000" and add the following values

   50
   80
   100
   150
   1050
   1100
then these values are grouped into two different bins, one between 0-999 and one between 1000-1999. In this example, you would have 4 values in the bin named "biggerThan0" and 2 values in the bin named "biggerThan1000".
See unit test for details.

Furthermore, if you specify a "maxLimit" as optional constructor argument, all values bigger than this maximum threshold will be grouped in one single bin (biggerThan) rather than grouped into separate bins as specified by "factor".

The "bins" are not sized automatically because this would require storing all added values so that the bin values could be re-calculated.

The HistogramLikeValue automatically creates counter and timer values in the background; the names of these Reportables are constructed using the "baseName" specified as constructor argument. In the end, the following InApplicationMonitor reportables are created by this class:
   <basename>.total                   Timer recording all values
   <basename>.biggerThan<value>       Counter for each bin that is created
   <basename>.currentMax              StateValue holding the current maximum value
 

Author:
ptraeder

Field Summary
private  String baseName
           
private  long currentMaxValue
           
private  long factor
           
private  String factorName
           
private  long maxLimit
           
private  String maxLimitName
           
private  String maxValueName
           
static String NAME_BIGGER_THAN
           
static String NAME_CURRENT_MAX
           
static String NAME_FACTOR
           
private  String timerName
           
 
Constructor Summary
HistogramLikeValue(String baseName, long factor)
           
HistogramLikeValue(String baseName, long factor, long maxLimit)
           
 
Method Summary
 void addValue(long newValue)
          adds a new value to the InApplicationMonitor, grouping it into the appropriate bin.
 String getBaseName()
           
private  String getBinName(long value)
           
private  void register(CorePlugin corePlugin)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME_BIGGER_THAN

public static final String NAME_BIGGER_THAN
See Also:
Constant Field Values

NAME_FACTOR

public static final String NAME_FACTOR
See Also:
Constant Field Values

NAME_CURRENT_MAX

public static final String NAME_CURRENT_MAX
See Also:
Constant Field Values

baseName

private String baseName

timerName

private String timerName

factorName

private String factorName

factor

private long factor

maxLimit

private long maxLimit

currentMaxValue

private long currentMaxValue

maxValueName

private String maxValueName

maxLimitName

private String maxLimitName
Constructor Detail

HistogramLikeValue

public HistogramLikeValue(String baseName,
                          long factor)
Parameters:
baseName - the base name to use for InApplicationMonitor value name
factor - the factor to divide new values by in order to group them into bins

HistogramLikeValue

public HistogramLikeValue(String baseName,
                          long factor,
                          long maxLimit)
Parameters:
baseName - the base name to use for InApplicationMonitor value name
factor - the factor to divide new values by in order to group them into bins
maxLimit - the upper limit up to which bins are created - all values bigger than maxLimit are grouped into one single bin
Method Detail

register

private void register(CorePlugin corePlugin)

getBaseName

public String getBaseName()

getBinName

private String getBinName(long value)

addValue

public void addValue(long newValue)
adds a new value to the InApplicationMonitor, grouping it into the appropriate bin.

Parameters:
newValue - the value that should be added


Copyright © 2013 Immobilien Scout GmbH. All Rights Reserved.