/** * Constructor that lets you choose whether downstream calls will be surrounded with a subspan. The default * {@link HttpTagAndSpanNamingStrategy} and {@link HttpTagAndSpanNamingAdapter} will be used * ({@link ZipkinHttpTagStrategy} and {@link SpringHttpClientTagAdapter}). * * @param surroundCallsWithSubspan pass in true to have downstream calls surrounded with a new span, false to only * propagate the current span's info downstream (no subspan). */ public WingtipsAsyncClientHttpRequestInterceptor(boolean surroundCallsWithSubspan) { this( surroundCallsWithSubspan, ZipkinHttpTagStrategy.<HttpRequest, ClientHttpResponse>getDefaultInstance(), SpringHttpClientTagAdapter.getDefaultInstance() ); }
/** * Constructor that lets you choose whether downstream calls will be surrounded with a subspan. The default * {@link HttpTagAndSpanNamingStrategy} and {@link HttpTagAndSpanNamingAdapter} will be used * ({@link ZipkinHttpTagStrategy} and {@link SpringHttpClientTagAdapter}). * * @param surroundCallsWithSubspan pass in true to have downstream calls surrounded with a new span, false to only * propagate the current span's info downstream (no subspan). */ public WingtipsClientHttpRequestInterceptor(boolean surroundCallsWithSubspan) { this( surroundCallsWithSubspan, ZipkinHttpTagStrategy.<HttpRequest, ClientHttpResponse>getDefaultInstance(), SpringHttpClientTagAdapter.getDefaultInstance() ); }
/** * Constructor that lets you choose whether downstream calls will be surrounded with a subspan. The default * {@link HttpTagAndSpanNamingStrategy} and {@link HttpTagAndSpanNamingAdapter} will be used * ({@link ZipkinHttpTagStrategy} and {@link SpringHttpClientTagAdapter}). * * @param surroundCallsWithSubspan pass in true to have downstream calls surrounded with a new span, false to only * propagate the current span's info downstream (no subspan). */ public WingtipsAsyncClientHttpRequestInterceptor(boolean surroundCallsWithSubspan) { this( surroundCallsWithSubspan, ZipkinHttpTagStrategy.<HttpRequest, ClientHttpResponse>getDefaultInstance(), SpringHttpClientTagAdapter.getDefaultInstance() ); }
/** * Constructor that lets you choose whether downstream calls will be surrounded with a subspan. The default * {@link HttpTagAndSpanNamingStrategy} and {@link HttpTagAndSpanNamingAdapter} will be used * ({@link ZipkinHttpTagStrategy} and {@link SpringHttpClientTagAdapter}). * * @param surroundCallsWithSubspan pass in true to have downstream calls surrounded with a new span, false to only * propagate the current span's info downstream (no subspan). */ public WingtipsClientHttpRequestInterceptor(boolean surroundCallsWithSubspan) { this( surroundCallsWithSubspan, ZipkinHttpTagStrategy.<HttpRequest, ClientHttpResponse>getDefaultInstance(), SpringHttpClientTagAdapter.getDefaultInstance() ); }
@Test public void getDefaultInstance_returns_DEFAULT_INSTANCE() { // expect assertThat(SpringHttpClientTagAdapter.getDefaultInstance()) .isSameAs(SpringHttpClientTagAdapter.DEFAULT_INSTANCE); }
@Test public void default_constructor_creates_instance_with_subspan_option_on() { // when WingtipsClientHttpRequestInterceptor interceptor = new WingtipsClientHttpRequestInterceptor(); // then assertThat(interceptor.surroundCallsWithSubspan).isTrue(); assertThat(interceptor.tagAndNamingStrategy).isSameAs(ZipkinHttpTagStrategy.getDefaultInstance()); assertThat(interceptor.tagAndNamingAdapter).isSameAs(SpringHttpClientTagAdapter.getDefaultInstance()); }
@Test public void default_constructor_creates_instance_with_subspan_option_on() { // when WingtipsAsyncClientHttpRequestInterceptor interceptor = new WingtipsAsyncClientHttpRequestInterceptor(); // then assertThat(interceptor.surroundCallsWithSubspan).isTrue(); assertThat(interceptor.tagAndNamingStrategy).isSameAs(ZipkinHttpTagStrategy.getDefaultInstance()); assertThat(interceptor.tagAndNamingAdapter).isSameAs(SpringHttpClientTagAdapter.getDefaultInstance()); }
@DataProvider(value = { "true", "false" }) @Test public void single_arg_constructor_creates_instance_with_subspan_option_set_to_desired_value( boolean subspanOptionOn ) { // when WingtipsClientHttpRequestInterceptor interceptor = new WingtipsClientHttpRequestInterceptor(subspanOptionOn); // then assertThat(interceptor.surroundCallsWithSubspan).isEqualTo(subspanOptionOn); assertThat(interceptor.tagAndNamingStrategy).isSameAs(ZipkinHttpTagStrategy.getDefaultInstance()); assertThat(interceptor.tagAndNamingAdapter).isSameAs(SpringHttpClientTagAdapter.getDefaultInstance()); }
@DataProvider(value = { "true", "false" }) @Test public void single_arg_constructor_creates_instance_with_subspan_option_set_to_desired_value( boolean subspanOptionOn ) { // when WingtipsAsyncClientHttpRequestInterceptor interceptor = new WingtipsAsyncClientHttpRequestInterceptor(subspanOptionOn); // then assertThat(interceptor.surroundCallsWithSubspan).isEqualTo(subspanOptionOn); assertThat(interceptor.tagAndNamingStrategy).isSameAs(ZipkinHttpTagStrategy.getDefaultInstance()); assertThat(interceptor.tagAndNamingAdapter).isSameAs(SpringHttpClientTagAdapter.getDefaultInstance()); }
@Test public void createTracingEnabledRestTemplate_no_args_returns_RestTemplate_with_wingtips_interceptor_added_with_expected_fields() { // when RestTemplate result = WingtipsSpringUtil.createTracingEnabledRestTemplate(); // then assertThat(result.getInterceptors()).hasSize(1); assertThat(result.getInterceptors().get(0)).isInstanceOf(WingtipsClientHttpRequestInterceptor.class); verifyInterceptorFieldValues( result.getInterceptors().get(0), true, ZipkinHttpTagStrategy.getDefaultInstance(), SpringHttpClientTagAdapter.getDefaultInstance() ); }
@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 createTracingEnabledRestTemplate_single_arg_returns_RestTemplate_with_wingtips_interceptor_added_with_expected_fields( boolean subspanOptionOn ) { // when RestTemplate result = WingtipsSpringUtil.createTracingEnabledRestTemplate(subspanOptionOn); // then assertThat(result.getInterceptors()).hasSize(1); assertThat(result.getInterceptors().get(0)).isInstanceOf(WingtipsClientHttpRequestInterceptor.class); verifyInterceptorFieldValues( result.getInterceptors().get(0), subspanOptionOn, ZipkinHttpTagStrategy.getDefaultInstance(), SpringHttpClientTagAdapter.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() ); }