Skip to content

Commit

Permalink
Add test for checking correct tracing context propagation.
Browse files Browse the repository at this point in the history
  • Loading branch information
pujagani committed Nov 18, 2020
1 parent 6329cf2 commit e38d58e
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,27 @@ public void shouldBeAbleToCreateATracer() {

}

@Test
public void shouldBeAbleToInjectContext() {
List<SpanData> allSpans = new ArrayList<>();
Tracer tracer = createTracer(allSpans);

HttpRequest cheeseReq = new HttpRequest(GET, "/cheeses");

assertThat(cheeseReq.getHeaderNames()).size().isEqualTo(0);

try (Span span = tracer.getCurrentContext().createSpan("parent")) {
span.setAttribute("cheese", "gouda");
span.setStatus(Status.NOT_FOUND);
tracer.getPropagator().inject(tracer.getCurrentContext(),
cheeseReq,
(req, key, value) -> req.setHeader("cheese", "gouda"));
}

assertThat(cheeseReq.getHeaderNames()).size().isEqualTo(1);
assertThat(cheeseReq.getHeaderNames()).element(0).isEqualTo("cheese");
}

@Test
public void shouldBeAbleToCreateASpanWithAEvent() {
List<SpanData> allSpans = new ArrayList<>();
Expand Down

0 comments on commit e38d58e

Please sign in to comment.