use of org.apache.beam.sdk.testutils.metrics.MetricsReader in project beam by apache.
the class TextIOIT method fillMetricSuppliers.
private Set<Function<MetricsReader, NamedTestResult>> fillMetricSuppliers(String uuid, String timestamp) {
Set<Function<MetricsReader, NamedTestResult>> metricSuppliers = new HashSet<>();
metricSuppliers.add((reader) -> {
long writeStartTime = reader.getStartTimeMetric("startTime");
long writeEndTime = reader.getEndTimeMetric("middleTime");
double writeTime = (writeEndTime - writeStartTime) / 1e3;
return NamedTestResult.create(uuid, timestamp, "write_time", writeTime);
});
metricSuppliers.add((reader) -> {
long readStartTime = reader.getStartTimeMetric("middleTime");
long readEndTime = reader.getEndTimeMetric("endTime");
double readTime = (readEndTime - readStartTime) / 1e3;
return NamedTestResult.create(uuid, timestamp, "read_time", readTime);
});
metricSuppliers.add((reader) -> {
long writeStartTime = reader.getStartTimeMetric("startTime");
long readEndTime = reader.getEndTimeMetric("endTime");
double runTime = (readEndTime - writeStartTime) / 1e3;
return NamedTestResult.create(uuid, timestamp, "run_time", runTime);
});
if (datasetSize != null) {
metricSuppliers.add((ignored) -> NamedTestResult.create(uuid, timestamp, "dataset_size", datasetSize));
}
if (gatherGcsPerformanceMetrics) {
metricSuppliers.add(reader -> {
MetricsReader actualReader = reader.withNamespace("org.apache.beam.sdk.extensions.gcp.storage.GcsFileSystem");
long numCopies = actualReader.getCounterMetric("num_copies");
long copyTimeMsec = actualReader.getCounterMetric("copy_time_msec");
double copiesPerSec = (numCopies < 0 || copyTimeMsec < 0) ? -1 : numCopies / (copyTimeMsec / 1e3);
return NamedTestResult.create(uuid, timestamp, "copies_per_sec", copiesPerSec);
});
}
return metricSuppliers;
}
Aggregations