Jagger
 All Classes Namespaces Files Functions Variables Enumerator Groups Pages
com.griddynamics.jagger.engine.e1.services.DefaultMetricService Class Reference

Implementation of the MetricService
. More...

Inheritance diagram for com.griddynamics.jagger.engine.e1.services.DefaultMetricService:

Public Member Functions

void createMetric (MetricDescription metricDescription)
 Creates metric. More...
 
 DefaultMetricService (String sessionId, String taskId, NodeContext context)
 
void flush ()
 Writes all values to file system. More...
 
boolean isAvailable ()
 Reports if service is available. More...
 
void saveValue (String metricId, Number value)
 Saves metric value during test run. More...
 
void saveValue (String metricId, Number value, long timeStamp)
 Saves metric value with specific timestamp during test run. More...
 

Static Public Attributes

static final String METRIC_MARKER = "METRIC"
 

Protected Attributes

NodeContext context
 
String sessionId
 
String taskId
 

Detailed Description

Implementation of the MetricService
.

Details:

Service gives an ability to create and describe metrics, save metric values.
Where this service is available you can find in chapter: Services
Below is example of creating metric with metric service. MetricDescription is used to setup how metric will be aggregated and stored
In the example we are creating metric before running performance test and saving values on every successful request to the SUT. After test is over, results for this metric will be aggregated by multiple aggregators. More details about metrics collection you can find in the chapter Collecting metrics

package com.griddynamics.jagger.engine.e1.collector.invocation;
import com.griddynamics.jagger.engine.e1.Provider;
import com.griddynamics.jagger.engine.e1.collector.AvgMetricAggregatorProvider;
import com.griddynamics.jagger.engine.e1.collector.MaxMetricAggregatorProvider;
import com.griddynamics.jagger.engine.e1.collector.MetricDescription;
import com.griddynamics.jagger.engine.e1.collector.MinMetricAggregatorProvider;
import com.griddynamics.jagger.engine.e1.collector.PercentileAggregatorProvider;
import com.griddynamics.jagger.engine.e1.collector.invocation.InvocationInfo;
import com.griddynamics.jagger.engine.e1.collector.invocation.InvocationListener;
import com.griddynamics.jagger.engine.e1.services.ServicesAware;
import com.griddynamics.jagger.invoker.InvocationException;
public class ExampleInvocationListener extends ServicesAware implements Provider<InvocationListener> {
private final String metricName = "example-duration-metric";
@Override
protected void init() {
//begin: following section is used for docu generation - example of the metric with multiple aggregators
getMetricService().createMetric(new MetricDescription(metricName)
.displayName("Example duration metric, ms")
.showSummary(true)
.plotData(true)
.addAggregator(new MinMetricAggregatorProvider())
.addAggregator(new MaxMetricAggregatorProvider())
.addAggregator(new AvgMetricAggregatorProvider())
.addAggregator(new PercentileAggregatorProvider(40D))
.addAggregator(new PercentileAggregatorProvider(50D))
.addAggregator(new PercentileAggregatorProvider(60D))
.addAggregator(new PercentileAggregatorProvider(70D))
.addAggregator(new PercentileAggregatorProvider(80D))
.addAggregator(new PercentileAggregatorProvider(90D))
.addAggregator(new PercentileAggregatorProvider(95D))
.addAggregator(new PercentileAggregatorProvider(99D))
);
//end: following section is used for docu generation - example of the metric with multiple aggregators
}
@Override
public InvocationListener provide() {
return new InvocationListener() {
@Override
public void onStart(InvocationInfo invocationInfo) { }
@Override
public void onSuccess(InvocationInfo invocationInfo) {
if (invocationInfo.getResult() != null) {
getMetricService().saveValue(metricName, invocationInfo.getDuration());
}
}
@Override
public void onFail(InvocationInfo invocationInfo, InvocationException e) { }
@Override
public void onError(InvocationInfo invocationInfo, Throwable error) { }
};
}
}


Definition at line 29 of file DefaultMetricService.java.


The documentation for this class was generated from the following file: