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:
@@ -6,6 +6,7 @@ import java.time.OffsetDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@@ -19,7 +20,7 @@ public class PlotSettings {
|
||||
|
||||
private int width;
|
||||
|
||||
private String groupBy;
|
||||
private List<String> groupBy;
|
||||
|
||||
private Limit limitBy;
|
||||
|
||||
@@ -53,11 +54,11 @@ public class PlotSettings {
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
public String getGroupBy() {
|
||||
public List<String> getGroupBy() {
|
||||
return groupBy;
|
||||
}
|
||||
|
||||
public void setGroupBy(final String groupBy) {
|
||||
public void setGroupBy(final List<String> groupBy) {
|
||||
this.groupBy = groupBy;
|
||||
}
|
||||
|
||||
|
||||
@@ -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(")");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user