group by multiple fields

Before we could only group by a single field. But it is acutally
very useful to group by multiple fields. For example to see the
graph for a small set of methods grouped by host and project.
This commit is contained in:
2017-04-12 19:16:19 +02:00
parent 6cc6e679a4
commit 8baf05962f
9 changed files with 169 additions and 72 deletions

View File

@@ -36,6 +36,8 @@ public class Plotter {
private static final Logger LOGGER = LoggerFactory.getLogger(Plotter.class);
private static final Logger METRICS_LOGGER = LoggerFactory.getLogger("org.lucares.metrics.plotter");
private static final String DEFAULT_GROUP = "<none>";
private final PerformanceDb db;
private final Path tmpBaseDir;
private final Path outputDir;
@@ -68,7 +70,7 @@ public class Plotter {
final List<DataSeries> dataSeries = new ArrayList<>();
final String query = plotSettings.getQuery();
final String groupBy = plotSettings.getGroupBy();
final List<String> groupBy = plotSettings.getGroupBy();
final int height = plotSettings.getHeight();
final int width = plotSettings.getWidth();
final OffsetDateTime dateFrom = plotSettings.dateFrom();
@@ -165,12 +167,18 @@ public class Plotter {
final StringBuilder result = new StringBuilder();
assert tags.getKeys().size() <= 1;
tags.forEach((k, v) -> {
result.append(v);
});
if (tags.isEmpty()) {
result.append(DEFAULT_GROUP);
} else {
tags.forEach((k, v) -> {
if (result.length() > 0) {
result.append(" / ");
}
result.append(v);
});
}
result.append("(");
result.append(" (");
result.append(values);
result.append(")");