@Test public void properties() { AsyncClientRequestAdapter<TextMap> adapter = sensor.getAsyncClientRequestAdapter(object, new Object[] { httpExchange }, rsc); assertThat(adapter.getPropagationType(), is(PropagationType.HTTP)); assertThat(adapter.getReferenceType(), is(References.FOLLOWS_FROM)); assertThat(adapter.getFormat(), is(Format.Builtin.HTTP_HEADERS)); verifyZeroInteractions(object, rsc); }
@Test public void mustHaveTheProperProperties() { AsyncClientRequestAdapter<TextMap> adapter = sensor.getAsyncClientRequestAdapter(object, new Object[] { null, httpRequest, httpContext, null }, rsc); assertThat("The propagation type must be HTTP.", adapter.getPropagationType(), is(PropagationType.HTTP)); assertThat("The reference type must be FOLLOWS FROM.", adapter.getReferenceType(), is(References.FOLLOWS_FROM)); assertThat("The format must be HTTP HEADER.", adapter.getFormat(), is(Format.Builtin.HTTP_HEADERS)); verifyZeroInteractions(object, rsc); }
@BeforeMethod public void setup() { when(requestAdapter.getFormat()).thenReturn(Format.Builtin.TEXT_MAP); when(requestAdapter.getCarrier()).thenReturn(carrier); when(requestAdapter.getSpanStoreAdapter()).thenReturn(spanStoreAdapter); when(tracer.buildSpan(anyString(), anyString(), anyBoolean())).thenReturn(spanBuilder); when(spanBuilder.build()).thenReturn(span); when(span.context()).thenReturn(context); }
/** * Handles the {@link ClientRequestAdapter}. This method should be called when new client * request is created. * * @param <C> * type of carrier adapter is providing * @param requestAdapter * {@link ClientRequestAdapter} providing necessary information. * @return Created span */ public <C> SpanImpl handleAsyncRequest(AsyncClientRequestAdapter<C> requestAdapter) { SpanBuilderImpl builder = handleRequestInternal(requestAdapter); // nothing to do if builder was not created if (null == builder) { return null; } // just build the span and store it for later start SpanImpl span = builder.build(); SpanStore spanStore = new SpanStore(); spanStore.storeSpan(span); requestAdapter.getSpanStoreAdapter().setSpanStore(spanStore); // inject here as the context is created when span is started tracer.inject(span.context(), requestAdapter.getFormat(), requestAdapter.getCarrier()); return span; }