@Override public @Nullable String doGetInitialSpanName( @NotNull RequestInfo<?> request ) { return tagAndNamingStrategy.getInitialSpanName(request, tagAndNamingAdapter); }
@Override public @Nullable String doGetInitialSpanName( @NotNull RequestBuilderWrapper request ) { return tagAndNamingStrategy.getInitialSpanName(request, tagAndNamingAdapter); }
@Override public @Nullable String doGetInitialSpanName( @NotNull RequestInfo<?> request ) { return tagAndNamingStrategy.getInitialSpanName(request, tagAndNamingAdapter); }
@Override protected @Nullable String doGetInitialSpanName(@NotNull HttpRequest request) { return tagAndNamingStrategy.getInitialSpanName(request, tagAndNamingAdapter); }
@Override protected @Nullable String doGetInitialSpanName(@NotNull HttpRequest request) { return tagAndNamingStrategy.getInitialSpanName(request, tagAndNamingAdapter); }
/** * Returns the name that should be used for the subspan surrounding the call. Defaults to whatever {@link * HttpTagAndSpanNamingStrategy#getInitialSpanName(Object, HttpTagAndSpanNamingAdapter)} returns, with a fallback * of {@link WingtipsApacheHttpClientUtil#getFallbackSubspanSpanName(HttpRequest)} if the naming strategy returned * null or blank string. You can override this method to return something else if you want different behavior and * you don't want to adjust the naming strategy or adapter. * * @param request The request that is about to be executed. * @param namingStrategy The {@link HttpTagAndSpanNamingStrategy} being used. * @param adapter The {@link HttpTagAndSpanNamingAdapter} being used. * @return The name that should be used for the subspan surrounding the call. */ protected @NotNull String getSubspanSpanName( @NotNull HttpRequest request, @NotNull HttpTagAndSpanNamingStrategy<HttpRequest, ?> namingStrategy, @NotNull HttpTagAndSpanNamingAdapter<HttpRequest, ?> adapter ) { // Try the naming strategy first. String subspanNameFromStrategy = namingStrategy.getInitialSpanName(request, adapter); if (StringUtils.isNotBlank(subspanNameFromStrategy)) { return subspanNameFromStrategy; } // The naming strategy didn't have anything for us. Fall back to something reasonable. return WingtipsApacheHttpClientUtil.getFallbackSubspanSpanName(request); }
/** * Returns the name that should be used for the subspan surrounding the call. Defaults to whatever {@link * HttpTagAndSpanNamingStrategy#getInitialSpanName(Object, HttpTagAndSpanNamingAdapter)} returns, with a fallback * of {@link WingtipsApacheHttpClientUtil#getFallbackSubspanSpanName(HttpRequest)} if the naming strategy returned * null or blank string. You can override this method to return something else if you want different behavior and * you don't want to adjust the naming strategy or adapter. * * @param request The request that is about to be executed. * @param namingStrategy The {@link HttpTagAndSpanNamingStrategy} being used. * @param adapter The {@link HttpTagAndSpanNamingAdapter} being used. * @return The name that should be used for the subspan surrounding the call. */ protected @NotNull String getSubspanSpanName( @NotNull HttpRequest request, @NotNull HttpTagAndSpanNamingStrategy<HttpRequest, ?> namingStrategy, @NotNull HttpTagAndSpanNamingAdapter<HttpRequest, ?> adapter ) { // Try the naming strategy first. String subspanNameFromStrategy = namingStrategy.getInitialSpanName(request, adapter); if (StringUtils.isNotBlank(subspanNameFromStrategy)) { return subspanNameFromStrategy; } // The naming strategy didn't have anything for us. Fall back to something reasonable. return WingtipsApacheHttpClientUtil.getFallbackSubspanSpanName(request); }
/** * @param request The incoming request. * @param namingStrategy The {@link HttpTagAndSpanNamingStrategy} that should be used to try and generate the * initial span name - cannot be null. * @param adapter The {@link HttpTagAndSpanNamingAdapter} that should be passed to the given {@code namingStrategy} * to try and generate the initial span name - cannot be null. * @return The human-readable name to be given to a {@link Span} representing this request. By default this method * attempts to use {@link HttpTagAndSpanNamingStrategy#getInitialSpanName(Object, HttpTagAndSpanNamingAdapter)} * with the given {@code namingStrategy} and {@code adapter} for generating the name, and falls back to * {@link HttpSpanFactory#getSpanName(HttpServletRequest)} if the {@link HttpTagAndSpanNamingStrategy} returns * null or blank. */ protected String getInitialSpanName( HttpServletRequest request, HttpTagAndSpanNamingStrategy<HttpServletRequest, ?> namingStrategy, HttpTagAndSpanNamingAdapter<HttpServletRequest, ?> adapter ) { // Try the naming strategy first. String spanNameFromStrategy = namingStrategy.getInitialSpanName(request, adapter); if (StringUtils.isNotBlank(spanNameFromStrategy)) { return spanNameFromStrategy; } // The naming strategy didn't have anything for us. Fall back to something reasonable. return HttpSpanFactory.getSpanName(request); }
/** * Returns the name that should be used for the subspan surrounding the call. Defaults to whatever {@link * HttpTagAndSpanNamingStrategy#getInitialSpanName(Object, HttpTagAndSpanNamingAdapter)} returns, with a fallback * of {@link HttpRequestTracingUtils#getFallbackSpanNameForHttpRequest(String, String)} if the naming strategy * returned null or blank string. You can override this method to return something else if you want different * behavior and you don't want to adjust the naming strategy or adapter. * * @param request The request that is about to be executed. * @param namingStrategy The {@link HttpTagAndSpanNamingStrategy} being used. * @param adapter The {@link HttpTagAndSpanNamingAdapter} being used. * @return The name that should be used for the subspan surrounding the call. */ protected @NotNull String getSubspanSpanName( @NotNull HttpRequest request, @NotNull HttpTagAndSpanNamingStrategy<HttpRequest, ?> namingStrategy, @NotNull HttpTagAndSpanNamingAdapter<HttpRequest, ?> adapter ) { // Try the naming strategy first. String subspanNameFromStrategy = namingStrategy.getInitialSpanName(request, adapter); if (StringUtils.isNotBlank(subspanNameFromStrategy)) { return subspanNameFromStrategy; } // The naming strategy didn't have anything for us. Fall back to something reasonable. return HttpRequestTracingUtils.getFallbackSpanNameForHttpRequest( "resttemplate_downstream_call", getRequestMethodAsString(request.getMethod()) ); } }
/** * Returns the name that should be used for the subspan surrounding the call. Defaults to whatever {@link * HttpTagAndSpanNamingStrategy#getInitialSpanName(Object, HttpTagAndSpanNamingAdapter)} returns, with a fallback * of {@link HttpRequestTracingUtils#getFallbackSpanNameForHttpRequest(String, String)} if the naming strategy * returned null or blank string. You can override this method to return something else if you want different * behavior and you don't want to adjust the naming strategy or adapter. * * @param request The request that is about to be executed. * @param namingStrategy The {@link HttpTagAndSpanNamingStrategy} being used. * @param adapter The {@link HttpTagAndSpanNamingAdapter} being used. * @return The name that should be used for the subspan surrounding the call. */ protected @NotNull String getSubspanSpanName( @NotNull HttpRequest request, @NotNull HttpTagAndSpanNamingStrategy<HttpRequest, ?> namingStrategy, @NotNull HttpTagAndSpanNamingAdapter<HttpRequest, ?> adapter ) { // Try the naming strategy first. String subspanNameFromStrategy = namingStrategy.getInitialSpanName(request, adapter); if (StringUtils.isNotBlank(subspanNameFromStrategy)) { return subspanNameFromStrategy; } // The naming strategy didn't have anything for us. Fall back to something reasonable. return HttpRequestTracingUtils.getFallbackSpanNameForHttpRequest( "asyncresttemplate_downstream_call", getRequestMethodAsString(request.getMethod()) ); }
/** * Returns the name that should be used for the subspan surrounding the call. Defaults to whatever {@link * HttpTagAndSpanNamingStrategy#getInitialSpanName(Object, HttpTagAndSpanNamingAdapter)} returns, with a fallback * of {@link HttpRequestTracingUtils#getFallbackSpanNameForHttpRequest(String, String)} if the naming strategy * returned null or blank string. You can override this method to return something else if you want different * behavior and you don't want to adjust the naming strategy or adapter. * * @param request The request that is about to be executed. * @param namingStrategy The {@link HttpTagAndSpanNamingStrategy} being used. * @param adapter The {@link HttpTagAndSpanNamingAdapter} being used. * @return The name that should be used for the subspan surrounding the call. */ protected @NotNull String getSubspanSpanName( @NotNull HttpRequest request, @NotNull HttpTagAndSpanNamingStrategy<HttpRequest, ?> namingStrategy, @NotNull HttpTagAndSpanNamingAdapter<HttpRequest, ?> adapter ) { // Try the naming strategy first. String subspanNameFromStrategy = namingStrategy.getInitialSpanName(request, adapter); if (StringUtils.isNotBlank(subspanNameFromStrategy)) { return subspanNameFromStrategy; } // The naming strategy didn't have anything for us. Fall back to something reasonable. return HttpRequestTracingUtils.getFallbackSpanNameForHttpRequest( "asyncresttemplate_downstream_call", getRequestMethodAsString(request.getMethod()) ); }
/** * Returns the name that should be used for the subspan surrounding the call. Defaults to whatever {@link * HttpTagAndSpanNamingStrategy#getInitialSpanName(Object, HttpTagAndSpanNamingAdapter)} returns, with a fallback * of {@link HttpRequestTracingUtils#getFallbackSpanNameForHttpRequest(String, String)} if the naming strategy * returned null or blank string. You can override this method to return something else if you want different * behavior and you don't want to adjust the naming strategy or adapter. * * @param request The request that is about to be executed. * @param namingStrategy The {@link HttpTagAndSpanNamingStrategy} being used. * @param adapter The {@link HttpTagAndSpanNamingAdapter} being used. * @return The name that should be used for the subspan surrounding the call. */ protected @NotNull String getSubspanSpanName( @NotNull HttpRequest request, @NotNull HttpTagAndSpanNamingStrategy<HttpRequest, ?> namingStrategy, @NotNull HttpTagAndSpanNamingAdapter<HttpRequest, ?> adapter ) { // Try the naming strategy first. String subspanNameFromStrategy = namingStrategy.getInitialSpanName(request, adapter); if (StringUtils.isNotBlank(subspanNameFromStrategy)) { return subspanNameFromStrategy; } // The naming strategy didn't have anything for us. Fall back to something reasonable. return HttpRequestTracingUtils.getFallbackSpanNameForHttpRequest( "resttemplate_downstream_call", getRequestMethodAsString(request.getMethod()) ); } }
@Test public void getInitialSpanName_defers_to_doGetInitialSpanName() { // given String delegateMethodResult = UUID.randomUUID().toString(); doReturn(delegateMethodResult) .when(implSpy).doGetInitialSpanName(anyObject(), any(HttpTagAndSpanNamingAdapter.class)); // when String result = implSpy.getInitialSpanName(requestObjectMock, adapterMock); // then assertThat(result).isEqualTo(delegateMethodResult); verify(implSpy).doGetInitialSpanName(requestObjectMock, adapterMock); verifyNoMoreInteractions(implSpy); verifyZeroInteractions(requestObjectMock, adapterMock); }
@Test public void getInitialSpanName_returns_null_if_delegate_method_throws_exception() { // given doThrow(new RuntimeException("boom")) .when(implSpy).doGetInitialSpanName(anyObject(), any(HttpTagAndSpanNamingAdapter.class)); // when String result = implSpy.getInitialSpanName(requestObjectMock, adapterMock); // then assertThat(result).isNull(); verify(implSpy).doGetInitialSpanName(requestObjectMock, adapterMock); verifyNoMoreInteractions(implSpy); verifyZeroInteractions(requestObjectMock, adapterMock); }
@DataProvider(value = { "REQUEST_OBJ_IS_NULL", "ADAPTER_IS_NULL", }, splitBy = "\\|") @Test @SuppressWarnings("ConstantConditions") public void getInitialSpanName_returns_null_in_null_arg_corner_cases(NullArgCornerCaseScenario scenario) { // given Object requestObjectMock = scenario.requestObjMock; HttpTagAndSpanNamingAdapter<Object, Object> adapterMock = scenario.adapterMock; // when String result = implSpy.getInitialSpanName(requestObjectMock, adapterMock); // then assertThat(result).isNull(); verifyZeroInteractions(implSpy); if (requestObjectMock != null) { verifyZeroInteractions(requestObjectMock); } if (adapterMock != null) { verifyZeroInteractions(adapterMock); } }