class InspectorResourceImpl implements InspectorResource {
    private static final Logger LOG = LoggerFactory.getLogger(InspectorResourceImpl.class);

    @Autowired
    private RestTemplate pluginRestTemplate;

    @Autowired
    private PluginAdapter pluginAdapter;

    @Autowired
    private DiscoveryClient discoveryClient;

    @Autowired(required = false)
    private PluginContextHolder pluginContextHolder;

    @Override
    public InspectorEntity inspect(InspectorEntity inspectorEntity) {
        List<String> serviceIdList = inspectorEntity.getServiceIdList();
        String result = inspectorEntity.getResult();

        // 第一个侦测节点，不会产生侦测信息，需要通过Header方式埋入 
        if (StringUtils.isEmpty(result) && pluginContextHolder != null) {
            result = pluginContextHolder.getContext(DiscoveryConstant.INSPECTOR_ENDPOINT_HEADER);
        }

        String pluginInfo = pluginAdapter.getPluginInfo(result);
        inspectorEntity.setResult(pluginInfo);

        if (CollectionUtils.isNotEmpty(serviceIdList)) {
            // 获取侦测列表中的第一个服务，作为下一个侦测中继节点
            String nextServiceId = serviceIdList.get(0);

            // 删除侦测列表中的第一个服务
            serviceIdList.remove(0);

            String url = null;
            try {
                ServiceInstance nextInstance = getInstance(nextServiceId);

                String protocol = pluginAdapter.getInstanceProtocol(nextInstance);
                String contextPath = pluginAdapter.getInstanceFormatContextPath(nextInstance);

                url = protocol + "://" + nextServiceId + contextPath + DiscoveryConstant.INSPECTOR_ENDPOINT_URL;

                // 直调方式需要走负载均衡模式下的RestTemplate
                return pluginRestTemplate.postForEntity(url, inspectorEntity, InspectorEntity.class).getBody();
            } catch (Exception e) {
                String exceptionMessage = "Failed to inspect, current serviceId=" + pluginAdapter.getServiceId() + ", next serviceId=" + nextServiceId + ", url=" + url;

                LOG.error(exceptionMessage, e);

                throw new DiscoveryException(exceptionMessage, e);
            }
        } else {
            return inspectorEntity;
        }
    }

    @Override
    public String inspect(List<String> service) {
        InspectorEntity inspectorEntity = new InspectorEntity();
        inspectorEntity.setServiceIdList(service);

        return inspect(inspectorEntity).getResult();
    }

    private ServiceInstance getInstance(String serviceId) {<FILL_FUNCTION_BODY>}
}

        List<ServiceInstance> instances = null;

        try {
            instances = discoveryClient.getInstances(serviceId);
        } catch (Exception e) {
            throw new DiscoveryException("Failed to get instance list, serviceId=" + serviceId, e);
        }

        if (CollectionUtils.isEmpty(instances)) {
            throw new DiscoveryException("Instance list is empty, serviceId=" + serviceId);
        }

        return instances.get(0);
    
<no_super_class>