Skip to content

Commit

Permalink
Refactor of RequestMonitoringCollector
Browse files Browse the repository at this point in the history
Implement an additional Collector and Comparator that will allow one to sum the transferred data of the responses for the given/filtered requests. Added a simple report that shows the information about the overall amount of the transferred data and the table of ordered requests (desc) and their attributes (URL as a link, Size in kilobytes)

wttech#501

I hereby agree to the terms of the AET Contributor License Agreement.
  • Loading branch information
Krzysztof Ryk committed Apr 9, 2019
1 parent 7e29ba6 commit 812f957
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.cognifide.aet.job.api.collector.WebCommunicationWrapper;
import com.cognifide.aet.job.api.exceptions.ParametersException;
import com.cognifide.aet.job.api.exceptions.ProcessingException;
import com.cognifide.aet.job.common.comparators.requestmonitoring.utils.RequestMonitoringResultBuilder;
import com.cognifide.aet.job.common.comparators.requestmonitoring.utils.RequestMonitoringResults;
import com.cognifide.aet.vs.ArtifactsDAO;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -55,18 +54,18 @@ public RequestMonitoringCollector(WebCommunicationWrapper webCommunicationWrappe
public CollectorStepResult collect() throws ProcessingException {
final CollectorStepResult stepResult;

RequestMonitoringResults result = new RequestMonitoringResults();
RequestMonitoringResults results = new RequestMonitoringResults();
HarLog log = webCommunicationWrapper.getProxyServer().getHar().getLog();

for (final HarEntry harLogEntry : log.getEntries()) {
String url = harLogEntry.getRequest().getUrl();
if (url.matches(urlPattern)) {
long bodySize = harLogEntry.getResponse().getBodySize();
result.addItem(new RequestMonitoringResultBuilder().setUrl(url).setSize(bodySize).build());
results.addItem(url, bodySize);
}
}

final String artifactId = artifactsDAO.saveArtifactInJsonFormat(properties, result);
final String artifactId = artifactsDAO.saveArtifactInJsonFormat(properties, results);
stepResult = CollectorStepResult.newCollectedResult(artifactId);

return stepResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public RequestMonitoringResults() {
this.totalSize = 0d;
}

public final void addItem(RequestMonitoringResult item) {
public final void addItem(String url, long bodySize) {
RequestMonitoringResult item = new RequestMonitoringResultBuilder().setUrl(url)
.setSize(bodySize).build();
results.add(item);
totalSize += item.getSize();
}
Expand Down

0 comments on commit 812f957

Please sign in to comment.