@Test public void testStartGtxSpanWhenSpanNotNullAndHasGtx() { final String name = "name"; final String gtx = "gtx"; final String traceId = "4e30f7340b3fb631"; final Span span = mock(Span.class, RETURNS_DEEP_STUBS); final Span newGlobalSpan = mock(Span.class); when(span.tags().containsKey("kermoss.gtx")).thenReturn(true); final Span result = kermossTracerUnderTest.startGtxSpan(name, gtx, traceId, span); verify(newGlobalSpan, never()).tag(anyString(), anyString()); verify(mockPublisher, never()).publishEvent(any(GtxSpanStarted.class)); assertEquals(result, span); }
public Span startGtxSpan(String name, String gtx, String traceId, Span span) { if (span == null || !hasGtx(span)) { Span newSpan = spanForId(traceId, span); Span newGlobalSpan = tracer.createSpan(name, newSpan); newGlobalSpan.tag("kermoss.gtx", gtx); if (span != null) { span.tags().forEach((k, v) -> { newGlobalSpan.tag(k, v); }); } publisher.publishEvent(new GtxSpanStarted()); log.info("Open new Span" + newGlobalSpan); return newGlobalSpan; } return span; }
KermossTracer { public Span startGtxSpan(String name, String gtx, String traceId, Span span) { if (span == null || !hasGtx(span)) { Span newSpan = spanForId(traceId, span); Span newGlobalSpan = tracer.createSpan(name, newSpan); newGlobalSpan.tag("kermoss.gtx", gtx); if (span != null) { span.tags().forEach((k, v) -> { newGlobalSpan.tag(k, v); }); } publisher.publishEvent(new GtxSpanStarted()); log.info("Open new Span" + newGlobalSpan); return newGlobalSpan; } return span; } }
KermossTracer { public Span startGtxSpan(String name, String gtx, String traceId, Span span) { if (span == null || !hasGtx(span)) { Span newSpan = spanForId(traceId, span); Span newGlobalSpan = tracer.createSpan(name, newSpan); newGlobalSpan.tag("kermoss.gtx", gtx); if (span != null) { span.tags().forEach((k, v) -> { newGlobalSpan.tag(k, v); }); } publisher.publishEvent(new GtxSpanStarted()); log.info("Open new Span" + newGlobalSpan); return newGlobalSpan; } return span; }  }
KermossTracer { public Span startGtxSpan(String name, String gtx, String traceId, Span span) { if (span == null || !hasGtx(span)) { Span newSpan = spanForId(traceId, span); Span newGlobalSpan = tracer.createSpan(name, newSpan); newGlobalSpan.tag("kermoss.gtx", gtx); if (span != null) { span.tags().forEach((k, v) -> { newGlobalSpan.tag(k, v); }); } publisher.publishEvent(new GtxSpanStarted()); log.info("Open new Span" + newGlobalSpan); return newGlobalSpan; } return span; }  @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) void closeSpan(GtxSpanStarted gtxSpanStarted); @TransactionalEventListener(phase = TransactionPhase.AFTER_ROLLBACK) void closeSpanE(GtxSpanStarted gtxSpanStarted); Span startGtxSpan(String name, String gtx, String traceId, Span span); Span startGtxSpan(GlobalTransaction gt, Span span); Span startNestedSpan(String name, String event, Span span); void closeSpan(Span span); Span currentSpan(); }
KermossTracer { public Span startGtxSpan(String name, String gtx, String traceId, Span span) { if (span == null || !hasGtx(span)) { Span newSpan = spanForId(traceId, span); Span newGlobalSpan = tracer.createSpan(name, newSpan); newGlobalSpan.tag("kermoss.gtx", gtx); if (span != null) { span.tags().forEach((k, v) -> { newGlobalSpan.tag(k, v); }); } publisher.publishEvent(new GtxSpanStarted()); log.info("Open new Span" + newGlobalSpan); return newGlobalSpan; } return span; }  @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) void closeSpan(GtxSpanStarted gtxSpanStarted); @TransactionalEventListener(phase = TransactionPhase.AFTER_ROLLBACK) void closeSpanE(GtxSpanStarted gtxSpanStarted); Span startGtxSpan(String name, String gtx, String traceId, Span span); Span startGtxSpan(GlobalTransaction gt, Span span); Span startNestedSpan(String name, String event, Span span); void closeSpan(Span span); Span currentSpan();  }