use of org.apache.jmeter.report.processor.FilterConsumer in project jmeter by apache.
the class ReportGenerator method createNameFilter.
/**
* @return a {@link FilterConsumer} that filters samplers based on their name
*/
private FilterConsumer createNameFilter() {
FilterConsumer nameFilter = new FilterConsumer();
nameFilter.setName(NAME_FILTER_CONSUMER_NAME);
nameFilter.setSamplePredicate(sample -> {
// Get filtered samples from configuration
Pattern filteredSamplesPattern = configuration.getFilteredSamplesPattern();
// or if its name matches the filter pattern
return filteredSamplesPattern == null || filteredSamplesPattern.matcher(sample.getName()).matches();
});
nameFilter.addSampleConsumer(createApdexSummaryConsumer());
nameFilter.addSampleConsumer(createRequestsSummaryConsumer());
nameFilter.addSampleConsumer(createStatisticsSummaryConsumer());
nameFilter.addSampleConsumer(createTop5ErrorsConsumer(configuration));
return nameFilter;
}
use of org.apache.jmeter.report.processor.FilterConsumer in project jmeter by apache.
the class ReportGenerator method generate.
/**
* Generate dashboard reports using the data from the specified CSV File.
*
* @throws GenerationException when the generation failed
*/
public void generate() throws GenerationException {
if (resultCollector != null) {
log.info("Flushing result collector before report Generation");
resultCollector.flushFile();
}
log.debug("Start report generation");
File tmpDir = configuration.getTempDirectory();
boolean tmpDirCreated = createTempDir(tmpDir);
// Build consumers chain
SampleContext sampleContext = new SampleContext();
sampleContext.setWorkingDirectory(tmpDir);
SampleSource source = new CsvFileSampleSource(testFile, CSV_DEFAULT_SEPARATOR);
source.setSampleContext(sampleContext);
NormalizerSampleConsumer normalizer = new NormalizerSampleConsumer();
normalizer.setName(NORMALIZER_CONSUMER_NAME);
FilterConsumer dateRangeConsumer = createFilterByDateRange();
dateRangeConsumer.addSampleConsumer(createBeginDateConsumer());
dateRangeConsumer.addSampleConsumer(createEndDateConsumer());
FilterConsumer nameFilter = createNameFilter();
FilterConsumer excludeControllerFilter = createExcludeControllerFilter();
nameFilter.addSampleConsumer(excludeControllerFilter);
dateRangeConsumer.addSampleConsumer(nameFilter);
normalizer.addSampleConsumer(dateRangeConsumer);
source.addSampleConsumer(normalizer);
// Get graph configurations
Map<String, GraphConfiguration> graphConfigurations = configuration.getGraphConfigurations();
// Process configuration to build graph consumers
for (Map.Entry<String, GraphConfiguration> entryGraphCfg : graphConfigurations.entrySet()) {
addGraphConsumer(nameFilter, excludeControllerFilter, entryGraphCfg);
}
// Generate data
log.debug("Start samples processing");
try {
// NOSONAR
source.run();
} catch (SampleException ex) {
throw new GenerationException("Error while processing samples: " + ex.getMessage(), ex);
}
log.debug("End of samples processing");
log.debug("Start data exporting");
// Process configuration to build data exporters
String key;
ExporterConfiguration value;
for (Map.Entry<String, ExporterConfiguration> entry : configuration.getExportConfigurations().entrySet()) {
key = entry.getKey();
value = entry.getValue();
if (log.isInfoEnabled()) {
log.info("Exporting data using exporter:'{}' of className:'{}'", key, value.getClassName());
}
exportData(sampleContext, key, value);
}
log.debug("End of data exporting");
removeTempDir(tmpDir, tmpDirCreated);
log.debug("End of report generation");
}
use of org.apache.jmeter.report.processor.FilterConsumer in project jmeter by apache.
the class ReportGenerator method createExcludeControllerFilter.
private FilterConsumer createExcludeControllerFilter() {
FilterConsumer excludeControllerFilter = new FilterConsumer();
excludeControllerFilter.setName(START_INTERVAL_CONTROLLER_FILTER_CONSUMER_NAME);
excludeControllerFilter.setSamplePredicate(new ControllerSamplePredicate());
excludeControllerFilter.setReverseFilter(true);
excludeControllerFilter.addSampleConsumer(createErrorsSummaryConsumer());
return excludeControllerFilter;
}
use of org.apache.jmeter.report.processor.FilterConsumer in project jmeter by apache.
the class ReportGenerator method createFilterByDateRange.
/**
* @return {@link FilterConsumer} that filter data based on date range
*/
@SuppressWarnings("JdkObsolete")
private FilterConsumer createFilterByDateRange() {
FilterConsumer dateRangeFilter = new FilterConsumer();
dateRangeFilter.setName(DATE_RANGE_FILTER_CONSUMER_NAME);
dateRangeFilter.setSamplePredicate(sample -> {
long sampleStartTime = sample.getStartTime();
if (configuration.getStartDate() != null) {
if (sampleStartTime >= configuration.getStartDate().getTime()) {
if (configuration.getEndDate() != null) {
return sampleStartTime <= configuration.getEndDate().getTime();
} else {
return true;
}
}
return false;
} else {
if (configuration.getEndDate() != null) {
return sampleStartTime <= configuration.getEndDate().getTime();
} else {
return true;
}
}
});
return dateRangeFilter;
}
Aggregations