Creating a Class with a Metric Function

Procedure

  1. Create a class that extends either SingleValueMetricFunction or MultiValueMetricFunction.

    public class MyMetric extends SingleValueMetricFunction{...}

  2. Override the init() method. The init() method belongs to the abstract class, AbstractMetricFunction.

    public void init(Fact fact, Measurement measurement, MetricNode startNode, DimensionHierarchy dh) throws java.lang.Exception

    For more information about the API, refer to the TIBCO Service Performance Manager Java API reference pages.

    The init() method has the one-time initialization of the metric function for a series of metric nodes starting at the leaf node and moving up to the parent node in the rollup hierarchy.

    For example, here you can store the current value for a sum computation. Then you can use this current value in the compute function at each level and add this current value to the existing sum at that level (Stored in the "context").

  3. Override the compute() method. This is where you load the previous state from RtaContext. Use the current value set in init() to compute the new value.
    public abstract compute(MetricNode metricNode, SingleValueMetric<N> metric, RtaNodeContext context)

    For more information about the API, refer to the TIBCO Service Performance Manager Java API reference pages.