/** * Returns the span name that should be used for the given request according to this strategy and/or the given * adapter. By default this will delegate to the adapter's {@link * HttpTagAndSpanNamingAdapter#getInitialSpanName(Object)} unless you override this method. * * <p><b>NOTE: This method may return null if the strategy and adapter have no opinion, or if something goes wrong. * Callers must always check for a null return value, and generate a backup span name in those cases.</b> * * <p>This method does the actual work for the public-facing {@link * #getInitialSpanName(Object, HttpTagAndSpanNamingAdapter)}. * * @param request The incoming request - will never be null. * @param adapter The adapter to handle the incoming request - will never be null. * * @return The span name that should be used for the given request according to this strategy and/or the given * adapter, or null if the span name should be deferred to the caller. */ protected @Nullable String doGetInitialSpanName( @NotNull REQ request, @NotNull HttpTagAndSpanNamingAdapter<REQ, ?> adapter ) { return adapter.getInitialSpanName(request); }
@Test public void doGetInitialSpanName_delegates_to_adapter_getInitialSpanName() { // given String adapterResult = UUID.randomUUID().toString(); doReturn(adapterResult).when(adapterMock).getInitialSpanName(anyObject()); // when String result = implSpy.doGetInitialSpanName(requestObjectMock, adapterMock); // then assertThat(result).isEqualTo(adapterResult); }
String initialSpanNameResult = implSpy.getInitialSpanName(new Object()); String finalSpanNameResult = implSpy.getFinalSpanName(new Object(), new Object());