in grpc-gcp/src/main/java/com/google/cloud/grpc/GcpMultiEndpointChannel.java [346:366]
private void updateMetricsForMultiEndpoint(GcpMultiEndpointOptions options, MultiEndpoint me) {
Set<String> newEndpoints = new HashSet<>(options.getEndpoints());
Set<String> existingEndpoints = new HashSet<>(me.getEndpoints());
for (String e : existingEndpoints) {
if (!newEndpoints.contains(e)) {
currentEndpointMetric.removeTimeSeries(
appendCommonValues(LabelValue.create(options.getName()), LabelValue.create(e)));
currentEndpointWatchers.remove(options.getName() + ":" + e);
}
}
for (String e : newEndpoints) {
if (!existingEndpoints.contains(e)) {
CurrentEndpointWatcher watcher = new CurrentEndpointWatcher(me, e);
currentEndpointWatchers.put(options.getName() + ":" + e, watcher);
currentEndpointMetric.createTimeSeries(
appendCommonValues(LabelValue.create(options.getName()), LabelValue.create(e)),
watcher,
CurrentEndpointWatcher::getMetricValue);
}
}
}