WIP on lists of measurements in results
This commit is contained in:
parent
9fd29e0f21
commit
d102d2f9fc
|
@ -59,6 +59,7 @@ public class ClientRouteBuilder extends RouteBuilder {
|
||||||
.log("Skipping empty measurement.")
|
.log("Skipping empty measurement.")
|
||||||
.stop()
|
.stop()
|
||||||
.otherwise()
|
.otherwise()
|
||||||
|
.log(">>> ${body}")
|
||||||
.to("seda:metrics?discardWhenFull=true");
|
.to("seda:metrics?discardWhenFull=true");
|
||||||
} else {
|
} else {
|
||||||
log.info(">>> Skipping extension (not supported here): " + ext.getDescription());
|
log.info(">>> Skipping extension (not supported here): " + ext.getDescription());
|
||||||
|
|
|
@ -2,6 +2,8 @@ package sysmon.shared;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class MetricResult implements Serializable {
|
public class MetricResult implements Serializable {
|
||||||
|
@ -11,7 +13,7 @@ public class MetricResult implements Serializable {
|
||||||
private String name;
|
private String name;
|
||||||
private String hostname;
|
private String hostname;
|
||||||
private Long timestamp; // epoch milli
|
private Long timestamp; // epoch milli
|
||||||
private Measurement measurement;
|
private List<Measurement> measurements;
|
||||||
|
|
||||||
public MetricResult() {
|
public MetricResult() {
|
||||||
}
|
}
|
||||||
|
@ -24,11 +26,25 @@ public class MetricResult implements Serializable {
|
||||||
public MetricResult(String name, Measurement measurement) {
|
public MetricResult(String name, Measurement measurement) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.timestamp = Instant.now().toEpochMilli();
|
this.timestamp = Instant.now().toEpochMilli();
|
||||||
this.measurement = measurement;
|
this.measurements = new ArrayList<Measurement>() {{
|
||||||
|
add(measurement);
|
||||||
|
}};
|
||||||
|
}
|
||||||
|
|
||||||
|
public MetricResult(String name, List<Measurement> measurements) {
|
||||||
|
this.name = name;
|
||||||
|
this.timestamp = Instant.now().toEpochMilli();
|
||||||
|
this.measurements = measurements;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMeasurement(Measurement measurement) {
|
public void setMeasurement(Measurement measurement) {
|
||||||
this.measurement = measurement;
|
this.measurements = new ArrayList<Measurement>() {{
|
||||||
|
add(measurement);
|
||||||
|
}};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMeasurements(List<Measurement> measurements) {
|
||||||
|
this.measurements = measurements;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHostname(String hostname) {
|
public void setHostname(String hostname) {
|
||||||
|
@ -56,21 +72,43 @@ public class MetricResult implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Measurement getMeasurement() {
|
public Measurement getMeasurement() {
|
||||||
return measurement;
|
if(measurements != null && measurements.size() > 0) {
|
||||||
|
return measurements.get(0);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Measurement> getMeasurements() {
|
||||||
|
if(measurements != null && measurements.size() > 0) {
|
||||||
|
return measurements;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder sb = new StringBuilder(String.format("%s - %s {", timestamp.toString(), name));
|
StringBuilder sb = new StringBuilder(String.format("%s - %s => ", timestamp.toString(), name));
|
||||||
|
|
||||||
if(measurement != null && measurement.getTags() != null) {
|
if(measurements != null && measurements.size() > 0) {
|
||||||
for (Map.Entry<String, String> entry : measurement.getTags().entrySet())
|
sb.append("{");
|
||||||
sb.append(" [").append(entry.getKey()).append(": ").append(entry.getValue()).append("]");
|
for(Measurement m : measurements) {
|
||||||
|
|
||||||
|
if(m != null && m.getTags() != null) {
|
||||||
|
for (Map.Entry<String, String> entry : m.getTags().entrySet())
|
||||||
|
sb.append(" [").append(entry.getKey()).append(": ").append(entry.getValue()).append("]");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(m != null && m.getFields() != null) {
|
||||||
|
for (Map.Entry<String,Object> entry : m.getFields().entrySet())
|
||||||
|
sb.append(" [").append(entry.getKey()).append(": ").append(entry.getValue()).append("]");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
sb.append("},");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(measurement != null && measurement.getFields() != null) {
|
|
||||||
for (Map.Entry<String,Object> entry : measurement.getFields().entrySet())
|
|
||||||
sb.append(" [").append(entry.getKey()).append(": ").append(entry.getValue()).append("]");
|
|
||||||
}
|
|
||||||
|
|
||||||
return sb.append(" }").toString();
|
return sb.append(" }").toString();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue