/** * @return A new {@link AsyncRestTemplate} instance with a {@link WingtipsAsyncClientHttpRequestInterceptor} * already added and configured to surround downstream calls with a subspan, and using the default * {@link HttpTagAndSpanNamingStrategy} and {@link HttpTagAndSpanNamingAdapter} ({@link ZipkinHttpTagStrategy} and * {@link SpringHttpClientTagAdapter}). */ public static AsyncRestTemplate createTracingEnabledAsyncRestTemplate() { return createTracingEnabledAsyncRestTemplate(true); }
/** * @return A new {@link AsyncRestTemplate} instance with a {@link WingtipsAsyncClientHttpRequestInterceptor} * already added and configured to surround downstream calls with a subspan, and using the default * {@link HttpTagAndSpanNamingStrategy} and {@link HttpTagAndSpanNamingAdapter} ({@link ZipkinHttpTagStrategy} and * {@link SpringHttpClientTagAdapter}). */ public static AsyncRestTemplate createTracingEnabledAsyncRestTemplate() { return createTracingEnabledAsyncRestTemplate(true); }
@DataProvider(value = { "NULL_STRATEGY_ARG", "NULL_ADAPTER_ARG" }) @Test public void createTracingEnabledAsyncRestTemplate_with_tag_and_span_naming_args_throws_IllegalArgumentException_if_passed_null_args( NullConstructorArgsScenario scenario ) { // when Throwable ex = catchThrowable( () -> WingtipsSpringUtil.createTracingEnabledAsyncRestTemplate(true, scenario.strategy, scenario.adapter) ); // then assertThat(ex) .isInstanceOf(IllegalArgumentException.class) .hasMessage(scenario.expectedExceptionMessage); }
@Test public void createTracingEnabledAsyncRestTemplate_no_args_returns_AsyncRestTemplate_with_wingtips_interceptor_added_with_expected_fields() { // when AsyncRestTemplate result = WingtipsSpringUtil.createTracingEnabledAsyncRestTemplate(); // then assertThat(result.getInterceptors()).hasSize(1); assertThat(result.getInterceptors().get(0)).isInstanceOf(WingtipsAsyncClientHttpRequestInterceptor.class); verifyInterceptorFieldValues( result.getInterceptors().get(0), true, ZipkinHttpTagStrategy.getDefaultInstance(), SpringHttpClientTagAdapter.getDefaultInstance() ); }
@DataProvider(value = { "true", "false" }) @Test public void createTracingEnabledAsyncRestTemplate_with_tag_and_span_naming_args_returns_AsyncRestTemplate_with_wingtips_interceptor_added_with_expected_fields( boolean subspanOptionOn ) { // when AsyncRestTemplate result = WingtipsSpringUtil.createTracingEnabledAsyncRestTemplate( subspanOptionOn, tagStrategyMock, tagAdapterMock ); // then assertThat(result.getInterceptors()).hasSize(1); assertThat(result.getInterceptors().get(0)).isInstanceOf(WingtipsAsyncClientHttpRequestInterceptor.class); verifyInterceptorFieldValues( result.getInterceptors().get(0), subspanOptionOn, tagStrategyMock, tagAdapterMock ); }
AsyncRestTemplate asyncRestTemplateWithWingtips = WingtipsSpringUtil.createTracingEnabledAsyncRestTemplate( subspanOptionOn, ZipkinHttpTagStrategy.getDefaultInstance(),
@DataProvider(value = { "true", "false" }) @Test public void createTracingEnabledAsyncRestTemplate_single_arg_returns_AsyncRestTemplate_with_wingtips_interceptor_added_with_expected_fields( boolean subspanOptionOn ) { // when AsyncRestTemplate result = WingtipsSpringUtil.createTracingEnabledAsyncRestTemplate(subspanOptionOn); // then assertThat(result.getInterceptors()).hasSize(1); assertThat(result.getInterceptors().get(0)).isInstanceOf(WingtipsAsyncClientHttpRequestInterceptor.class); verifyInterceptorFieldValues( result.getInterceptors().get(0), subspanOptionOn, ZipkinHttpTagStrategy.getDefaultInstance(), SpringHttpClientTagAdapter.getDefaultInstance() ); }