HttpTagAndSpanNamingStrategy { protected void doDetermineAndSetFinalSpanName( @NotNull Span span, @Nullable REQ request, @Nullable RES response, @Nullable Throwable error, @NotNull HttpTagAndSpanNamingAdapter<REQ, RES> adapter ) { String finalSpanName = adapter.getFinalSpanName(request, response); if (StringUtils.isNotBlank(finalSpanName)) { SpanMutator.changeSpanName(span, finalSpanName); } }  final @Nullable String getInitialSpanName(
        @NotNull REQ request,
        @NotNull HttpTagAndSpanNamingAdapter<REQ, ?> adapter
    ); final void handleRequestTagging(
        @NotNull Span span,
        @NotNull REQ request,
        @NotNull HttpTagAndSpanNamingAdapter<REQ, ?> adapter
    ); final void handleResponseTaggingAndFinalSpanName(
        @NotNull Span span,
        @Nullable REQ request,
        @Nullable RES response,
        @Nullable Throwable error,
        @NotNull HttpTagAndSpanNamingAdapter<REQ, RES> adapter
    );  }
@Test public void doDetermineAndSetFinalSpanName_delegates_to_adapter_getFinalSpanName_and_changes_span_name_if_result_is_not_blank() { String adapterSpanNameResult = UUID.randomUUID().toString(); doReturn(adapterSpanNameResult).when(adapterMock).getFinalSpanName(anyObject(), anyObject()); Span span = Span.newBuilder("originalSpanName", SpanPurpose.SERVER).build(); assertThat(span.getSpanName()).isNotEqualTo(adapterSpanNameResult); implSpy.doDetermineAndSetFinalSpanName(span, requestObjectMock, responseObjectMock, errorMock, adapterMock); assertThat(span.getSpanName()).isEqualTo(adapterSpanNameResult); verify(adapterMock).getFinalSpanName(requestObjectMock, responseObjectMock); }
@DataProvider(value = { "null", "", "[whitespace]" }, splitBy = "\\|") @Test public void doDetermineAndSetFinalSpanName_delegates_to_adapter_getFinalSpanName_and_does_NOT_change_span_name_if_result_IS_blank( String blankAdapterResult ) { if ("[whitespace]".equals(blankAdapterResult)) { blankAdapterResult = " \n\r\t "; } doReturn(blankAdapterResult).when(adapterMock).getFinalSpanName(anyObject(), anyObject()); String originalSpanName = "originalSpanName"; Span span = Span.newBuilder(originalSpanName, SpanPurpose.SERVER).build(); implSpy.doDetermineAndSetFinalSpanName(span, requestObjectMock, responseObjectMock, errorMock, adapterMock); assertThat(span.getSpanName()).isEqualTo(originalSpanName); verify(adapterMock).getFinalSpanName(requestObjectMock, responseObjectMock); }