JaegerTChannelCollectorHandler extends ThriftRequestHandler<Collector.submitBatches_args,
    Collector.submitBatches_result> implements Runnable, Closeable { @Override public ThriftResponse<Collector.submitBatches_result> handleImpl( ThriftRequest<Collector.submitBatches_args> request) { for (Batch batch : request.getBody(Collector.submitBatches_args.class).getBatches()) { try { processBatch(batch, null, DEFAULT_SOURCE, proxyLevelApplicationName, spanHandler, spanLogsHandler, wfInternalReporter, traceDisabled, spanLogsDisabled, preprocessorSupplier, sampler, traceDerivedCustomTagKeys, discardedTraces, discardedBatches, discardedSpansBySampler, discoveredHeartbeatMetrics, receivedSpansTotal); processedBatches.inc(); } catch (Exception e) { failedBatches.inc(); logger.log(Level.WARNING, "Jaeger Thrift batch processing failed", Throwables.getRootCause(e)); } } return new ThriftResponse.Builder<Collector.submitBatches_result>(request) .setBody(new Collector.submitBatches_result()) .build(); } JaegerTChannelCollectorHandler(String handle,
                                        ReportableEntityHandlerFactory handlerFactory,
                                        @Nullable WavefrontSender wfSender,
                                        Supplier<Boolean> traceDisabled,
                                        Supplier<Boolean> spanLogsDisabled,
                                        @Nullable Supplier<ReportableEntityPreprocessor> preprocessor,
                                        SpanSampler sampler,
                                        @Nullable String traceJaegerApplicationName,
                                        Set<String> traceDerivedCustomTagKeys);  JaegerTChannelCollectorHandler(String handle,
                                        ReportableEntityHandler<Span, String> spanHandler,
                                        ReportableEntityHandler<SpanLogs, String> spanLogsHandler,
                                        @Nullable WavefrontSender wfSender,
                                        Supplier<Boolean> traceDisabled,
                                        Supplier<Boolean> spanLogsDisabled,
                                        @Nullable Supplier<ReportableEntityPreprocessor> preprocessor,
                                        SpanSampler sampler,
                                        @Nullable String traceJaegerApplicationName,
                                        Set<String> traceDerivedCustomTagKeys); @Override ThriftResponse<Collector.submitBatches_result> handleImpl(
      ThriftRequest<Collector.submitBatches_args> request); @Override void run(); @Override void close();  }
@Test public void testJaegerTChannelCollector() throws Exception { reset(mockTraceHandler, mockTraceLogsHandler); Span expectedSpan1 = Span.newBuilder().setCustomer("dummy").setStartMillis(startTime) .setDuration(1234) .setName("HTTP GET") .setSource(DEFAULT_SOURCE) .setSpanId("00000000-0000-0000-0000-00000012d687") .setTraceId("00000000-4996-02d2-0000-011f71fb04cb") .setAnnotations(ImmutableList.of( new Annotation("ip", "10.0.0.1"), new Annotation("jaegerSpanId", "12d687"), new Annotation("jaegerTraceId", "499602d20000011f71fb04cb"), new Annotation("service", "frontend"), new Annotation("component", "db"), new Annotation("application", "Jaeger"), new Annotation("cluster", "none"), new Annotation("shard", "none"), new Annotation("_spanLogs", "true"))) .build(); mockTraceHandler.report(expectedSpan1); expectLastCall(); mockTraceLogsHandler.report(SpanLogs.newBuilder(). setCustomer("default"). setSpanId("00000000-0000-0000-0000-00000012d687"). setTraceId("00000000-4996-02d2-0000-011f71fb04cb"). setLogs(ImmutableList.of( SpanLog.newBuilder(). setTimestamp(startTime * 1000). setFields(ImmutableMap.of("event", "error", "exception", "NullPointerException")). build() )). build()); expectLastCall(); mockTraceHandler.report(Span.newBuilder().setCustomer("dummy").setStartMillis(startTime) .setDuration(2345) .setName("HTTP GET /") .setSource(DEFAULT_SOURCE) .setSpanId("00000000-0000-0000-0000-00000023cace") .setTraceId("00000000-4996-02d2-0000-011f71fb04cb") .setAnnotations(ImmutableList.of( new Annotation("ip", "10.0.0.1"), new Annotation("jaegerSpanId", "23cace"), new Annotation("jaegerTraceId", "499602d20000011f71fb04cb"), new Annotation("service", "frontend"), new Annotation("parent", "00000000-0000-0000-0000-00000012d687"), new Annotation("component", "db"), new Annotation("application", "Custom-JaegerApp"), new Annotation("cluster", "none"), new Annotation("shard", "none"))) .build()); expectLastCall(); mockTraceHandler.report(Span.newBuilder().setCustomer("dummy").setStartMillis(startTime) .setDuration(3456) .setName("HTTP GET /") .setSource(DEFAULT_SOURCE) .setSpanId("00000000-0000-0000-9a12-b85901d53397") .setTraceId("00000000-0000-0000-fea4-87ee36e58cab") .setAnnotations(ImmutableList.of( new Annotation("ip", "10.0.0.1"), new Annotation("jaegerSpanId", "9a12b85901d53397"), new Annotation("jaegerTraceId", "fea487ee36e58cab"), new Annotation("service", "frontend"), new Annotation("parent", "00000000-0000-0000-fea4-87ee36e58cab"), new Annotation("application", "Jaeger"), new Annotation("cluster", "none"), new Annotation("shard", "none"))) .build()); expectLastCall(); mockTraceHandler.report(Span.newBuilder().setCustomer("dummy").setStartMillis(startTime) .setDuration(3456) .setName("HTTP GET /test") .setSource(DEFAULT_SOURCE) .setSpanId("00000000-0000-0000-0000-0051759bfc69") .setTraceId("0000011e-ab2a-9944-0000-000049631900") .setAnnotations(ImmutableList.of( new Annotation("ip", "10.0.0.1"), new Annotation("jaegerSpanId", "51759bfc69"), new Annotation("jaegerTraceId", "11eab2a99440000000049631900"), new Annotation("service", "frontend"), new Annotation("application", "Jaeger"), new Annotation("cluster", "none"), new Annotation("shard", "none"))) .build()); expectLastCall(); replay(mockTraceHandler, mockTraceLogsHandler); JaegerTChannelCollectorHandler handler = new JaegerTChannelCollectorHandler("9876", mockTraceHandler, mockTraceLogsHandler, null, () -> false, () -> false, null, new SpanSampler(new RateSampler(1.0D), false), null, null); Tag ipTag = new Tag("ip", TagType.STRING); ipTag.setVStr("10.0.0.1"); Tag componentTag = new Tag("component", TagType.STRING); componentTag.setVStr("db"); Tag customApplicationTag = new Tag("application", TagType.STRING); customApplicationTag.setVStr("Custom-JaegerApp"); Tag emptyTag = new Tag("empty", TagType.STRING); emptyTag.setVStr(""); io.jaegertracing.thriftjava.Span span1 = new io.jaegertracing.thriftjava.Span(1234567890123L, 1234567890L, 1234567L, 0L, "HTTP GET", 1, startTime * 1000, 1234 * 1000); io.jaegertracing.thriftjava.Span span2 = new io.jaegertracing.thriftjava.Span(1234567890123L, 1234567890L, 2345678L, 1234567L, "HTTP GET /", 1, startTime * 1000, 2345 * 1000); io.jaegertracing.thriftjava.Span span3 = new io.jaegertracing.thriftjava.Span(-97803834702328661L, 0L, -7344605349865507945L, -97803834702328661L, "HTTP GET /", 1, startTime * 1000, 3456 * 1000); io.jaegertracing.thriftjava.Span span4 = new io.jaegertracing.thriftjava.Span(1231231232L, 1231232342340L, 349865507945L, 0, "HTTP GET /test", 1, startTime * 1000, 3456 * 1000); span1.setTags(ImmutableList.of(componentTag)); span2.setTags(ImmutableList.of(componentTag, customApplicationTag)); span4.setTags(ImmutableList.of(emptyTag)); Tag tag1 = new Tag("event", TagType.STRING); tag1.setVStr("error"); Tag tag2 = new Tag("exception", TagType.STRING); tag2.setVStr("NullPointerException"); span1.setLogs(ImmutableList.of(new Log(startTime * 1000, ImmutableList.of(tag1, tag2)))); Batch testBatch = new Batch(); testBatch.process = new Process(); testBatch.process.serviceName = "frontend"; testBatch.process.setTags(ImmutableList.of(ipTag)); testBatch.setSpans(ImmutableList.of(span1, span2, span3, span4)); Collector.submitBatches_args batches = new Collector.submitBatches_args(); batches.addToBatches(testBatch); ThriftRequest<Collector.submitBatches_args> request = new ThriftRequest.Builder<Collector.submitBatches_args>( "jaeger-collector", "Collector::submitBatches").setBody(batches).build(); handler.handleImpl(request); verify(mockTraceHandler, mockTraceLogsHandler); }
@Test public void testApplicationTagPriority() throws Exception { reset(mockTraceHandler, mockTraceLogsHandler); mockTraceHandler.report(Span.newBuilder().setCustomer("dummy").setStartMillis(startTime) .setDuration(1234) .setName("HTTP GET") .setSource(DEFAULT_SOURCE) .setSpanId("00000000-0000-0000-0000-00000012d687") .setTraceId("00000000-4996-02d2-0000-011f71fb04cb") .setAnnotations(ImmutableList.of( new Annotation("ip", "10.0.0.1"), new Annotation("jaegerSpanId", "12d687"), new Annotation("jaegerTraceId", "499602d20000011f71fb04cb"), new Annotation("service", "frontend"), new Annotation("component", "db"), new Annotation("application", "SpanLevelAppTag"), new Annotation("cluster", "none"), new Annotation("shard", "none"))) .build()); expectLastCall(); mockTraceHandler.report(Span.newBuilder().setCustomer("dummy").setStartMillis(startTime) .setDuration(2345) .setName("HTTP GET /") .setSource(DEFAULT_SOURCE) .setSpanId("00000000-0000-0000-0000-00000023cace") .setTraceId("00000000-4996-02d2-0000-011f71fb04cb") .setAnnotations(ImmutableList.of( new Annotation("ip", "10.0.0.1"), new Annotation("jaegerSpanId", "23cace"), new Annotation("jaegerTraceId", "499602d20000011f71fb04cb"), new Annotation("service", "frontend"), new Annotation("parent", "00000000-0000-0000-0000-00000012d687"), new Annotation("component", "db"), new Annotation("application", "ProcessLevelAppTag"), new Annotation("cluster", "none"), new Annotation("shard", "none"))) .build()); expectLastCall(); mockTraceHandler.report(Span.newBuilder().setCustomer("dummy").setStartMillis(startTime) .setDuration(3456) .setName("HTTP GET /") .setSource(DEFAULT_SOURCE) .setSpanId("00000000-0000-0000-9a12-b85901d53397") .setTraceId("00000000-0000-0000-fea4-87ee36e58cab") .setAnnotations(ImmutableList.of( new Annotation("ip", "10.0.0.1"), new Annotation("jaegerSpanId", "9a12b85901d53397"), new Annotation("jaegerTraceId", "fea487ee36e58cab"), new Annotation("service", "frontend"), new Annotation("parent", "00000000-0000-0000-fea4-87ee36e58cab"), new Annotation("application", "ProxyLevelAppTag"), new Annotation("cluster", "none"), new Annotation("shard", "none"))) .build()); expectLastCall(); replay(mockTraceHandler, mockTraceLogsHandler); JaegerTChannelCollectorHandler handler = new JaegerTChannelCollectorHandler("9876", mockTraceHandler, mockTraceLogsHandler, null, () -> false, () -> false, null, new SpanSampler(new RateSampler(1.0D), false), "ProxyLevelAppTag", null); Tag ipTag = new Tag("ip", TagType.STRING); ipTag.setVStr("10.0.0.1"); Tag componentTag = new Tag("component", TagType.STRING); componentTag.setVStr("db"); Tag spanLevelAppTag = new Tag("application", TagType.STRING); spanLevelAppTag.setVStr("SpanLevelAppTag"); Tag processLevelAppTag = new Tag("application", TagType.STRING); processLevelAppTag.setVStr("ProcessLevelAppTag"); io.jaegertracing.thriftjava.Span span1 = new io.jaegertracing.thriftjava.Span(1234567890123L, 1234567890L, 1234567L, 0L, "HTTP GET", 1, startTime * 1000, 1234 * 1000); io.jaegertracing.thriftjava.Span span2 = new io.jaegertracing.thriftjava.Span(1234567890123L, 1234567890L, 2345678L, 1234567L, "HTTP GET /", 1, startTime * 1000, 2345 * 1000); io.jaegertracing.thriftjava.Span span3 = new io.jaegertracing.thriftjava.Span(-97803834702328661L, 0L, -7344605349865507945L, -97803834702328661L, "HTTP GET /", 1, startTime * 1000, 3456 * 1000); span1.setTags(ImmutableList.of(componentTag, spanLevelAppTag)); span2.setTags(ImmutableList.of(componentTag)); Batch testBatch = new Batch(); testBatch.process = new Process(); testBatch.process.serviceName = "frontend"; testBatch.process.setTags(ImmutableList.of(ipTag, processLevelAppTag)); testBatch.setSpans(ImmutableList.of(span1, span2)); Collector.submitBatches_args batches = new Collector.submitBatches_args(); batches.addToBatches(testBatch); ThriftRequest<Collector.submitBatches_args> request = new ThriftRequest.Builder<Collector.submitBatches_args>( "jaeger-collector", "Collector::submitBatches").setBody(batches).build(); handler.handleImpl(request); Batch testBatchForProxyLevel = new Batch(); testBatchForProxyLevel.process = new Process(); testBatchForProxyLevel.process.serviceName = "frontend"; testBatchForProxyLevel.process.setTags(ImmutableList.of(ipTag)); testBatchForProxyLevel.setSpans(ImmutableList.of(span3)); Collector.submitBatches_args batchesForProxyLevel = new Collector.submitBatches_args(); batchesForProxyLevel.addToBatches(testBatchForProxyLevel); ThriftRequest<Collector.submitBatches_args> requestForProxyLevel = new ThriftRequest. Builder<Collector.submitBatches_args>("jaeger-collector", "Collector::submitBatches"). setBody(batchesForProxyLevel). build(); handler.handleImpl(requestForProxyLevel); verify(mockTraceHandler, mockTraceLogsHandler); }
@Test public void testJaegerDurationSampler() throws Exception { reset(mockTraceHandler, mockTraceLogsHandler); Span expectedSpan2 = Span.newBuilder().setCustomer("dummy").setStartMillis(startTime) .setDuration(9) .setName("HTTP GET /") .setSource(DEFAULT_SOURCE) .setSpanId("00000000-0000-0000-0000-00000023cace") .setTraceId("00000000-4996-02d2-0000-011f71fb04cb") .setAnnotations(ImmutableList.of( new Annotation("ip", "10.0.0.1"), new Annotation("jaegerSpanId", "23cace"), new Annotation("jaegerTraceId", "499602d20000011f71fb04cb"), new Annotation("service", "frontend"), new Annotation("parent", "00000000-0000-0000-0000-00000012d687"), new Annotation("application", "Jaeger"), new Annotation("cluster", "none"), new Annotation("shard", "none"), new Annotation("_spanLogs", "true"))) .build(); mockTraceHandler.report(expectedSpan2); expectLastCall(); mockTraceLogsHandler.report(SpanLogs.newBuilder(). setCustomer("default"). setSpanId("00000000-0000-0000-0000-00000023cace"). setTraceId("00000000-4996-02d2-0000-011f71fb04cb"). setLogs(ImmutableList.of( SpanLog.newBuilder(). setTimestamp(startTime * 1000). setFields(ImmutableMap.of("event", "error", "exception", "NullPointerException")). build() )). build()); expectLastCall(); replay(mockTraceHandler, mockTraceLogsHandler); JaegerTChannelCollectorHandler handler = new JaegerTChannelCollectorHandler("9876", mockTraceHandler, mockTraceLogsHandler, null, () -> false, () -> false, null, new SpanSampler(new DurationSampler(5), false), null, null); Tag ipTag = new Tag("ip", TagType.STRING); ipTag.setVStr("10.0.0.1"); io.jaegertracing.thriftjava.Span span1 = new io.jaegertracing.thriftjava.Span(1234567890123L, 1234567890L, 1234567L, 0L, "HTTP GET", 1, startTime * 1000, 4 * 1000); io.jaegertracing.thriftjava.Span span2 = new io.jaegertracing.thriftjava.Span(1234567890123L, 1234567890L, 2345678L, 1234567L, "HTTP GET /", 1, startTime * 1000, 9 * 1000); Tag tag1 = new Tag("event", TagType.STRING); tag1.setVStr("error"); Tag tag2 = new Tag("exception", TagType.STRING); tag2.setVStr("NullPointerException"); span1.setLogs(ImmutableList.of(new Log(startTime * 1000, ImmutableList.of(tag1, tag2)))); span2.setLogs(ImmutableList.of(new Log(startTime * 1000, ImmutableList.of(tag1, tag2)))); Batch testBatch = new Batch(); testBatch.process = new Process(); testBatch.process.serviceName = "frontend"; testBatch.process.setTags(ImmutableList.of(ipTag)); testBatch.setSpans(ImmutableList.of(span1, span2)); Collector.submitBatches_args batches = new Collector.submitBatches_args(); batches.addToBatches(testBatch); ThriftRequest<Collector.submitBatches_args> request = new ThriftRequest.Builder<Collector.submitBatches_args>( "jaeger-collector", "Collector::submitBatches").setBody(batches).build(); handler.handleImpl(request); verify(mockTraceHandler, mockTraceLogsHandler); }
@Test public void testJaegerDebugOverride() throws Exception { reset(mockTraceHandler, mockTraceLogsHandler); Span expectedSpan1 = Span.newBuilder().setCustomer("dummy").setStartMillis(startTime) .setDuration(9) .setName("HTTP GET /") .setSource(DEFAULT_SOURCE) .setSpanId("00000000-0000-0000-0000-00000023cace") .setTraceId("00000000-4996-02d2-0000-011f71fb04cb") .setAnnotations(ImmutableList.of( new Annotation("ip", "10.0.0.1"), new Annotation("jaegerSpanId", "23cace"), new Annotation("jaegerTraceId", "499602d20000011f71fb04cb"), new Annotation("service", "frontend"), new Annotation("parent", "00000000-0000-0000-0000-00000012d687"), new Annotation("debug", "true"), new Annotation("application", "Jaeger"), new Annotation("cluster", "none"), new Annotation("shard", "none"), new Annotation("_spanLogs", "true"))) .build(); mockTraceHandler.report(expectedSpan1); expectLastCall(); mockTraceLogsHandler.report(SpanLogs.newBuilder(). setCustomer("default"). setSpanId("00000000-0000-0000-0000-00000023cace"). setTraceId("00000000-4996-02d2-0000-011f71fb04cb"). setLogs(ImmutableList.of( SpanLog.newBuilder(). setTimestamp(startTime * 1000). setFields(ImmutableMap.of("event", "error", "exception", "NullPointerException")). build() )). build()); expectLastCall(); Span expectedSpan2 = Span.newBuilder().setCustomer("dummy").setStartMillis(startTime) .setDuration(4) .setName("HTTP GET") .setSource(DEFAULT_SOURCE) .setSpanId("00000000-0000-0000-0000-00000012d687") .setTraceId("00000000-4996-02d2-0000-011f71fb04cb") .setAnnotations(ImmutableList.of( new Annotation("ip", "10.0.0.1"), new Annotation("jaegerSpanId", "12d687"), new Annotation("jaegerTraceId", "499602d20000011f71fb04cb"), new Annotation("service", "frontend"), new Annotation("sampling.priority", "0.3"), new Annotation("application", "Jaeger"), new Annotation("cluster", "none"), new Annotation("shard", "none"), new Annotation("_spanLogs", "true"))) .build(); mockTraceHandler.report(expectedSpan2); expectLastCall(); mockTraceLogsHandler.report(SpanLogs.newBuilder(). setCustomer("default"). setSpanId("00000000-0000-0000-0000-00000012d687"). setTraceId("00000000-4996-02d2-0000-011f71fb04cb"). setLogs(ImmutableList.of( SpanLog.newBuilder(). setTimestamp(startTime * 1000). setFields(ImmutableMap.of("event", "error", "exception", "NullPointerException")). build() )). build()); expectLastCall(); replay(mockTraceHandler, mockTraceLogsHandler); JaegerTChannelCollectorHandler handler = new JaegerTChannelCollectorHandler("9876", mockTraceHandler, mockTraceLogsHandler, null, () -> false, () -> false, null, new SpanSampler(new DurationSampler(10), false), null, null); Tag ipTag = new Tag("ip", TagType.STRING); ipTag.setVStr("10.0.0.1"); Tag debugTag = new Tag("debug", TagType.STRING); debugTag.setVStr("true"); io.jaegertracing.thriftjava.Span span1 = new io.jaegertracing.thriftjava.Span(1234567890123L, 1234567890L, 2345678L, 1234567L, "HTTP GET /", 1, startTime * 1000, 9 * 1000); span1.setTags(ImmutableList.of(debugTag)); Tag samplePriorityTag = new Tag("sampling.priority", TagType.DOUBLE); samplePriorityTag.setVDouble(0.3); io.jaegertracing.thriftjava.Span span2 = new io.jaegertracing.thriftjava.Span(1234567890123L, 1234567890L, 1234567L, 0L, "HTTP GET", 1, startTime * 1000, 4 * 1000); span2.setTags(ImmutableList.of(samplePriorityTag)); Tag tag1 = new Tag("event", TagType.STRING); tag1.setVStr("error"); Tag tag2 = new Tag("exception", TagType.STRING); tag2.setVStr("NullPointerException"); span1.setLogs(ImmutableList.of(new Log(startTime * 1000, ImmutableList.of(tag1, tag2)))); span2.setLogs(ImmutableList.of(new Log(startTime * 1000, ImmutableList.of(tag1, tag2)))); Batch testBatch = new Batch(); testBatch.process = new Process(); testBatch.process.serviceName = "frontend"; testBatch.process.setTags(ImmutableList.of(ipTag)); testBatch.setSpans(ImmutableList.of(span1, span2)); Collector.submitBatches_args batches = new Collector.submitBatches_args(); batches.addToBatches(testBatch); ThriftRequest<Collector.submitBatches_args> request = new ThriftRequest.Builder<Collector.submitBatches_args>( "jaeger-collector", "Collector::submitBatches").setBody(batches).build(); handler.handleImpl(request); verify(mockTraceHandler, mockTraceLogsHandler); }
@Test public void testSourceTagPriority() throws Exception { reset(mockTraceHandler, mockTraceLogsHandler); mockTraceHandler.report(Span.newBuilder().setCustomer("dummy").setStartMillis(startTime) .setDuration(9) .setName("HTTP GET /") .setSource("source-spantag") .setSpanId("00000000-0000-0000-0000-00000023cace") .setTraceId("00000000-4996-02d2-0000-011f71fb04cb") .setAnnotations(ImmutableList.of( new Annotation("ip", "10.0.0.1"), new Annotation("jaegerSpanId", "23cace"), new Annotation("jaegerTraceId", "499602d20000011f71fb04cb"), new Annotation("service", "frontend"), new Annotation("parent", "00000000-0000-0000-0000-00000012d687"), new Annotation("application", "Jaeger"), new Annotation("cluster", "none"), new Annotation("shard", "none"))) .build()); expectLastCall(); mockTraceHandler.report(Span.newBuilder().setCustomer("dummy").setStartMillis(startTime) .setDuration(4) .setName("HTTP GET") .setSource("source-processtag") .setSpanId("00000000-0000-0000-0000-00000012d687") .setTraceId("00000000-4996-02d2-0000-011f71fb04cb") .setAnnotations(ImmutableList.of( new Annotation("ip", "10.0.0.1"), new Annotation("jaegerSpanId", "12d687"), new Annotation("jaegerTraceId", "499602d20000011f71fb04cb"), new Annotation("service", "frontend"), new Annotation("application", "Jaeger"), new Annotation("cluster", "none"), new Annotation("shard", "none"))) .build()); expectLastCall(); mockTraceHandler.report(Span.newBuilder().setCustomer("dummy").setStartMillis(startTime) .setDuration(3456) .setName("HTTP GET /test") .setSource("hostname-processtag") .setSpanId("00000000-0000-0000-0000-0051759bfc69") .setTraceId("0000011e-ab2a-9944-0000-000049631900") .setAnnotations(ImmutableList.of( new Annotation("ip", "10.0.0.1"), new Annotation("jaegerSpanId", "51759bfc69"), new Annotation("jaegerTraceId", "11eab2a99440000000049631900"), new Annotation("service", "frontend"), new Annotation("application", "Jaeger"), new Annotation("cluster", "none"), new Annotation("shard", "none"))) .build()); expectLastCall(); replay(mockTraceHandler, mockTraceLogsHandler); JaegerTChannelCollectorHandler handler = new JaegerTChannelCollectorHandler("9876", mockTraceHandler, mockTraceLogsHandler, null, () -> false, () -> false, null, new SpanSampler(new RateSampler(1.0D), false), null, null); Tag ipTag = new Tag("ip", TagType.STRING); ipTag.setVStr("10.0.0.1"); Tag hostNameProcessTag = new Tag("hostname", TagType.STRING); hostNameProcessTag.setVStr("hostname-processtag"); Tag customSourceProcessTag = new Tag("source", TagType.STRING); customSourceProcessTag.setVStr("source-processtag"); Tag customSourceSpanTag = new Tag("source", TagType.STRING); customSourceSpanTag.setVStr("source-spantag"); io.jaegertracing.thriftjava.Span span1 = new io.jaegertracing.thriftjava.Span(1234567890123L, 1234567890L, 2345678L, 1234567L, "HTTP GET /", 1, startTime * 1000, 9 * 1000); span1.setTags(ImmutableList.of(customSourceSpanTag)); io.jaegertracing.thriftjava.Span span2 = new io.jaegertracing.thriftjava.Span(1234567890123L, 1234567890L, 1234567L, 0L, "HTTP GET", 1, startTime * 1000, 4 * 1000); io.jaegertracing.thriftjava.Span span3 = new io.jaegertracing.thriftjava.Span(1231231232L, 1231232342340L, 349865507945L, 0, "HTTP GET /test", 1, startTime * 1000, 3456 * 1000); Batch testBatch = new Batch(); testBatch.process = new Process(); testBatch.process.serviceName = "frontend"; testBatch.process.setTags(ImmutableList.of(ipTag, hostNameProcessTag, customSourceProcessTag)); testBatch.setSpans(ImmutableList.of(span1, span2)); Collector.submitBatches_args batches = new Collector.submitBatches_args(); batches.addToBatches(testBatch); ThriftRequest<Collector.submitBatches_args> request = new ThriftRequest.Builder<Collector.submitBatches_args>( "jaeger-collector", "Collector::submitBatches").setBody(batches).build(); handler.handleImpl(request); Batch testBatchSourceAsProcessTagHostName = new Batch(); testBatchSourceAsProcessTagHostName.process = new Process(); testBatchSourceAsProcessTagHostName.process.serviceName = "frontend"; testBatchSourceAsProcessTagHostName.process.setTags(ImmutableList.of(ipTag, hostNameProcessTag)); testBatchSourceAsProcessTagHostName.setSpans(ImmutableList.of(span3)); Collector.submitBatches_args batchesSourceAsProcessTagHostName = new Collector.submitBatches_args(); batchesSourceAsProcessTagHostName.addToBatches(testBatchSourceAsProcessTagHostName); ThriftRequest<Collector.submitBatches_args> requestForProxyLevel = new ThriftRequest. Builder<Collector.submitBatches_args>("jaeger-collector", "Collector::submitBatches"). setBody(batchesSourceAsProcessTagHostName). build(); handler.handleImpl(requestForProxyLevel); verify(mockTraceHandler, mockTraceLogsHandler); }