@Override
public Map<String, String> getAnnotations(Kind kind) {
if (kind == Kind.SERVICE) {
String prometheusPort = findPrometheusPort();
if (Strings.isNotBlank(prometheusPort)) {
log.verbose("Add prometheus.io annotations: %s=%s, %s=%S",
Annotations.Management.PROMETHEUS_SCRAPE, "true",
Annotations.Management.PROMETHEUS_PORT, prometheusPort);
Map<String, String> annotations = new HashMap<>();
MapUtil.putIfAbsent(annotations, Annotations.Management.PROMETHEUS_PORT, prometheusPort);
MapUtil.putIfAbsent(annotations, Annotations.Management.PROMETHEUS_SCRAPE, "true");
return annotations;
}
}
return super.getAnnotations(kind);
}