Source:
public Response postRequest(GatewayAccountEntity account, OrderRequestType requestType, URI url, String payload, String authHeaderValue, MediaType mediaType) { String metricsPrefix = format("gateway-operations.%s.%s.%s", account.getGatewayName(), account.getType(), requestType); Stopwatch responseTimeStopwatch = Stopwatch.createStarted(); try { logger.info("POSTing request for account '{}' with type '{}'", account.getGatewayName(), account.getType()); Response response = client.target(url.toString()) .request() .header(AUTHORIZATION, authHeaderValue) .post(Entity.entity(payload, mediaType)); if (response.getStatusInfo().getFamily() == Response.Status.Family.SERVER_ERROR) { incrementFailureCounter(metricRegistry, metricsPrefix); throw new WebApplicationException("Unexpected HTTP status code " + response.getStatus() + " from gateway"); } return response; } catch (ProcessingException pe) { incrementFailureCounter(metricRegistry, metricsPrefix); if (pe.getCause() != null) { if (pe.getCause() instanceof UnknownHostException) { logger.error(format("DNS resolution error for gateway url=%s", url.toString()), pe); throw new WebApplicationException("Gateway Url DNS resolution error"); } if (pe.getCause() instanceof SocketTimeoutException) { logger.error(format("Connection timed out error for gateway url=%s", url.toString()), pe); throw new WebApplicationException("Gateway connection timeout error"); } if (pe.getCause() instanceof SocketException) { logger.error(format("Socket Exception for gateway url=%s", url.toString()), pe); throw new WebApplicationException("Gateway connection socket error"); } } logger.error(format("Exception for gateway url=%s", url.toString()), pe); throw new WebApplicationException(pe.getMessage()); } catch (Exception e) { incrementFailureCounter(metricRegistry, metricsPrefix); logger.error(format("Exception for gateway url=%s", url.toString()), e); throw new WebApplicationException(e.getMessage()); } finally { responseTimeStopwatch.stop(); metricRegistry.histogram(metricsPrefix + ".response_time").update(responseTimeStopwatch.elapsed(TimeUnit.MILLISECONDS)); } }

Target:
public Response postRequest(GatewayAccountEntity account, OrderRequestType requestType, URI url, String payload, String authHeaderValue, MediaType mediaType) { String metricsPrefix = format("gateway-operations.%s.%s.%s", account.getGatewayName(), account.getType(), requestType); Stopwatch responseTimeStopwatch = Stopwatch.createStarted(); try { logger.info("POSTing request for account '{}' with type '{}'", account.getGatewayName(), account.getType()); Response response = client.target(url.toString()) .request() .header(AUTHORIZATION, authHeaderValue) .post(Entity.entity(payload, mediaType)); if (response.getStatusInfo().getFamily() == Response.Status.Family.SERVER_ERROR) { logger.error("Stripe gateway returned server error: {}, for gateway url={} with type {}", response.getStatus(), url.toString(), account.getType()); incrementFailureCounter(metricRegistry, metricsPrefix); throw new WebApplicationException("Unexpected HTTP status code " + response.getStatus() + " from gateway"); } return response; } catch (ProcessingException pe) { incrementFailureCounter(metricRegistry, metricsPrefix); if (pe.getCause() != null) { if (pe.getCause() instanceof UnknownHostException) { logger.error(format("DNS resolution error for gateway url=%s", url.toString()), pe); throw new WebApplicationException("Gateway Url DNS resolution error"); } if (pe.getCause() instanceof SocketTimeoutException) { logger.error(format("Connection timed out error for gateway url=%s", url.toString()), pe); throw new WebApplicationException("Gateway connection timeout error"); } if (pe.getCause() instanceof SocketException) { logger.error(format("Socket Exception for gateway url=%s", url.toString()), pe); throw new WebApplicationException("Gateway connection socket error"); } } logger.error(format("Exception for gateway url=%s", url.toString()), pe); throw new WebApplicationException(pe.getMessage()); } catch (Exception e) { incrementFailureCounter(metricRegistry, metricsPrefix); logger.error(format("Exception for gateway url=%s", url.toString()), e); throw new WebApplicationException(e.getMessage()); } finally { responseTimeStopwatch.stop(); metricRegistry.histogram(metricsPrefix + ".response_time").update(responseTimeStopwatch.elapsed(TimeUnit.MILLISECONDS)); } }