public void submitAnnotation(String name, String value) { if (enabled) { clientTracer.submitAnnotation(value); } } public void stopServerTracer()
public void submitFailure() { if (enabled) { clientTracer.submitAnnotation(FAILURE_ANNOTATION); } }
/** * Interface method implementation. Interprets the response and submits suitable annotation to the client tracer and also marks receipt of the response on it. * @see com.flipkart.phantom.task.spi.interceptor.ResponseInterceptor#process(java.lang.Object) */ public void process(S response, Optional<RuntimeException> transportError) { ClientTracer clientTracer = Brave.getClientTracer(this.eventDispatchingSpanCollector, this.traceFilters); if (transportError.isPresent()) { clientTracer.submitAnnotation(FAILURE_ANNOTATION); } else { final Optional<Integer> statusCode = this.getResponseStatusCode(response); if (statusCode.isPresent()) { clientTracer.submitBinaryAnnotation(RESPONSE_CODE_ANNOTATION, statusCode.get()); } if (!this.isResponseSuccess(response)) { // In this case response will be the error message. clientTracer.submitAnnotation(FAILURE_ANNOTATION); } } clientTracer.setClientReceived(); }
/** * Handles a Client Response. * * @param clientResponseAdapter */ public void handle(final ClientResponseAdapter clientResponseAdapter) { try { final int responseStatus = clientResponseAdapter.getStatusCode(); clientTracer.submitBinaryAnnotation(HTTP_RESPONSE_CODE_ANNOTATION, responseStatus); if (responseStatus < 200 || responseStatus > 299) { // In this case response will be the error message. clientTracer.submitAnnotation(FAILURE_ANNOTATION); } } finally { clientTracer.setClientReceived(); } } }