class MatchingServiceHealthCheckClient {

    public MatchingServiceHealthCheckResponseDto sendHealthCheckRequest(
            final Element matchingServiceHealthCheckRequest,
            final URI matchingServiceUri) {

        // Use a custom timer so that we get separate metrics for each matching service
        final String scope = matchingServiceUri.toString().replace(':','_').replace('/', '_');
        final Timer timer = metricsRegistry.timer(MetricRegistry.name(MatchingServiceHealthCheckClient.class, "sendHealthCheckRequest", scope));
        final Timer.Context context = timer.time();
        HealthCheckResponse healthCheckResponse;
        try {
            healthCheckResponse = client.makeSoapRequestForHealthCheck(matchingServiceHealthCheckRequest, matchingServiceUri);
        } catch(ApplicationException ex) {
            final String errorMessage = MessageFormat.format("Failed to complete matching service health check to {0}.", matchingServiceUri);
            LOG.warn(errorMessage, ex);
            return new MatchingServiceHealthCheckResponseDto(Optional.empty());
        } finally {
            context.stop();
        }

        return new MatchingServiceHealthCheckResponseDto(
                    Optional.of(XmlUtils.writeToString(healthCheckResponse.getResponseElement())));
    }

    @Inject public  MatchingServiceHealthCheckClient(HealthCheckSoapRequestClient soapRequestClient, MetricRegistry metricsRegistry);

}