br.com.oncast.dev.lobo
Class Telemetry

java.lang.Object
  extended by br.com.oncast.dev.lobo.Telemetry

public class Telemetry
extends java.lang.Object

Telemetry collector.
Telemetry is used to collect profiling metrics in each profile scenario.
It is simple to define metrics in your scenario, take a look at the example:

   @Profile
   public void profileForLoop() throws Exception {
     for (int i=0;i<1000;i++) {
       for (int j=0;j<100;j++) Thread.sleep(10);
     }
   }
 
In this code the default metric "scenario-timespan" will collect the overall time of the method execution which will be something like 1000000 milliseconds. But imagine that what is to be mesured is not the performance of all code, what is to be done is to test the for (int j=0;j<100;j++) Thread.sleep(10); line 1000 times and collect the average result.
This can be done by defining a new metric, let's say "100-sleep", and properly invoke telemetry. This is the final code:
   @Profile
   public void profileForLoop() throws Exception {
     for (int i=0;i<1000;i++) {
       Telemetry.startMetric("100-sleep",MetricType.AVERAGE);
       for (int j=0;j<100;j++) Thread.sleep(10);
       Telemetry.endMetric("100-sleep");
     }
   }
 


Constructor Summary
Telemetry()
           
 
Method Summary
static void endMetric(java.lang.String metricName)
          Ends collecting the given metric.
static void startMetric(java.lang.String metricName)
          Starts collecting the given metric.
static void startMetric(java.lang.String metricName, MetricType type)
          Starts collecting the given metric.
static void switchMetric(java.lang.String metricName)
          Switches the metric.
Only valid for multi valored metrics.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Telemetry

public Telemetry()
Method Detail

startMetric

public static void startMetric(java.lang.String metricName)
Starts collecting the given metric.

Parameters:
metricName - the metric name.

startMetric

public static void startMetric(java.lang.String metricName,
                               MetricType type)
Starts collecting the given metric.

Parameters:
metricName - the metric name.
type - the metric collection type.

switchMetric

public static void switchMetric(java.lang.String metricName)
Switches the metric.
Only valid for multi valored metrics.

Parameters:
metricName - the metric name.

endMetric

public static void endMetric(java.lang.String metricName)
Ends collecting the given metric.

Parameters:
metricName - the metric name.