OpenTracingHttpTagStrategy extends HttpTagAndSpanNamingStrategy<REQ, RES> { @Override protected void doHandleResponseAndErrorTagging( @NotNull Span span, @Nullable REQ request, @Nullable RES response, @Nullable Throwable error, @NotNull HttpTagAndSpanNamingAdapter<REQ, RES> adapter ) { putTagIfValueIsNotBlank(span, KnownOpenTracingTags.HTTP_STATUS, adapter.getResponseHttpStatus(response)); if (error != null || StringUtils.isNotBlank(adapter.getErrorResponseTagValue(response))) { span.putTag(KnownOpenTracingTags.ERROR, "true"); } }  @SuppressWarnings("unchecked") static OpenTracingHttpTagStrategy<REQ, RES> getDefaultInstance();  }
@DataProvider(value = { "ERROR_IS_NOT_NULL", "ERROR_IS_NULL_BUT_ADAPTER_ERROR_TAG_VALUE_IS_NOT_BLANK", "ERROR_IS_NULL_AND_ADAPTER_ERROR_TAG_VALUE_IS_NULL", "ERROR_IS_NULL_AND_ADAPTER_ERROR_TAG_VALUE_IS_EMPTY", "ERROR_IS_NULL_AND_ADAPTER_ERROR_TAG_VALUE_IS_WHITESPACE" }) @Test public void doHandleResponseAndErrorTagging_puts_expected_tags_based_on_adapter_results_and_error_existence( ErrorTaggingScenario scenario ) { Integer adapterHttpStatus = 42; doReturn(adapterHttpStatus).when(adapterMock).getResponseHttpStatus(anyObject()); doReturn(scenario.adapterErrorTagValue).when(adapterMock).getErrorResponseTagValue(anyObject()); implSpy.doHandleResponseAndErrorTagging(spanMock, requestMock, responseMock, scenario.error, adapterMock); verify(adapterMock).getResponseHttpStatus(responseMock); verify(implSpy).putTagIfValueIsNotBlank(spanMock, KnownOpenTracingTags.HTTP_STATUS, adapterHttpStatus); if (scenario.error == null) { verify(adapterMock).getErrorResponseTagValue(responseMock); } else { verify(adapterMock, never()).getErrorResponseTagValue(anyObject()); } if (scenario.expectErrorTagPutOnSpan) { verify(spanMock).putTag(KnownOpenTracingTags.ERROR, "true"); } }