void monitor(ApplicationInfo applicationInfo) {
        if (!applicationInfo.getApplicationId().equals(applicationId)) {
            throw new IllegalArgumentException("Monitors " + applicationId + " but was asked to monitor " + applicationInfo.getApplicationId());
        }

        Map<ServiceId, HealthEndpoint> endpoints = healthModel.extractHealthEndpoints(applicationInfo);

        synchronized (guard) {
            // Remove obsolete monitors
            Set<ServiceId> removed = new HashSet<>(monitors.keySet());
            removed.removeAll(endpoints.keySet());
            removed.stream().map(monitors::remove).forEach(HealthMonitor::close);

            // Add new monitors.
            endpoints.forEach((serviceId, endpoint) -> monitors.computeIfAbsent(serviceId, ignoredId -> endpoint.startMonitoring()));
        }
    }
Responsible for monitoring a whole application using /state/v1/health.

@author hakon
service-monitor/src/main/java/com/yahoo/vespa/service/health/ApplicationHealthMonitor.java