pl.allegro.tech.hermes.management.infrastructure.prometheus.PrometheusResponse Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hermes-management Show documentation
Show all versions of hermes-management Show documentation
Fast and reliable message broker built on top of Kafka.
package pl.allegro.tech.hermes.management.infrastructure.prometheus;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
import java.util.Optional;
record PrometheusResponse(@JsonProperty("status") String status, @JsonProperty("data") Data data) {
boolean isSuccess() {
return status.equals("success") && data.isVector();
}
record Data(
@JsonProperty("resultType") String resultType,
@JsonProperty("result") List results) {
boolean isVector() {
return resultType.equals("vector");
}
}
@JsonIgnoreProperties(ignoreUnknown = true)
record VectorResult(@JsonProperty("value") List vector) {
private static final int VALID_VECTOR_LENGTH = 2;
private static final int SCALAR_INDEX_VALUE = 1;
Optional getValue() {
if (vector.size() != VALID_VECTOR_LENGTH) {
return Optional.empty();
}
return Optional.of(Double.parseDouble(vector.get(SCALAR_INDEX_VALUE)));
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy