@Test public void testApplicationTagPriority() throws Exception { reset(mockTraceHandler, mockTraceLogsHandler); mockTraceHandler.report(Span.newBuilder().setCustomer("dummy").setStartMillis(startTime) .setDuration(1000) .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("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(2000) .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("service", "frontend"), new Annotation("component", "db"), new Annotation("application", "ProcessLevelAppTag"), new Annotation("cluster", "none"), new Annotation("shard", "none"), new Annotation("parent", "00000000-0000-0000-0000-00000012d687"))) .build()); expectLastCall(); mockTraceHandler.report(Span.newBuilder().setCustomer("dummy").setStartMillis(startTime) .setDuration(3000) .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("service", "frontend"), new Annotation("application", "ProxyLevelAppTag"), new Annotation("cluster", "none"), new Annotation("shard", "none"), new Annotation("parent", "00000000-0000-0000-fea4-87ee36e58cab"))) .build()); expectLastCall(); replay(mockTraceHandler, mockTraceLogsHandler); JaegerGrpcCollectorHandler handler = new JaegerGrpcCollectorHandler("9876", mockTraceHandler, mockTraceLogsHandler, null, () -> false, () -> false, null, new SpanSampler(new RateSampler(1.0D), false), "ProxyLevelAppTag", null); Model.KeyValue ipTag = Model.KeyValue.newBuilder(). setKey("ip"). setVStr("10.0.0.1"). setVType(Model.ValueType.STRING). build(); Model.KeyValue componentTag = Model.KeyValue.newBuilder(). setKey("component"). setVStr("db"). setVType(Model.ValueType.STRING). build(); Model.KeyValue spanLevelAppTag = Model.KeyValue.newBuilder(). setKey("application"). setVStr("SpanLevelAppTag"). setVType(Model.ValueType.STRING). build(); Model.KeyValue processLevelAppTag = Model.KeyValue.newBuilder(). setKey("application"). setVStr("ProcessLevelAppTag"). setVType(Model.ValueType.STRING). build(); ByteBuffer buffer = ByteBuffer.allocate(Long.BYTES * 2); buffer.putLong(1234567890L); buffer.putLong(1234567890123L); ByteString traceId = ByteString.copyFrom(buffer.array()); buffer = ByteBuffer.allocate(Long.BYTES * 2); buffer.putLong(0L); buffer.putLong(-97803834702328661L); ByteString trace2Id = ByteString.copyFrom(buffer.array()); buffer = ByteBuffer.allocate(Long.BYTES); buffer.putLong(1234567L); ByteString span1Id = ByteString.copyFrom(buffer.array()); buffer = ByteBuffer.allocate(Long.BYTES); buffer.putLong(2345678L); ByteString span2Id = ByteString.copyFrom(buffer.array()); buffer = ByteBuffer.allocate(Long.BYTES); buffer.putLong(-7344605349865507945L); ByteString span3Id = ByteString.copyFrom(buffer.array()); buffer = ByteBuffer.allocate(Long.BYTES); buffer.putLong(-97803834702328661L); ByteString span3ParentId = ByteString.copyFrom(buffer.array()); Model.Span span1 = Model.Span.newBuilder(). setTraceId(traceId). setSpanId(span1Id). setDuration(Duration.newBuilder().setSeconds(1L).build()). setOperationName("HTTP GET"). setStartTime(fromMillis(startTime)). addTags(componentTag). addTags(spanLevelAppTag). setFlags(1). build(); Model.Span span2 = Model.Span.newBuilder(). setTraceId(traceId). setSpanId(span2Id). setDuration(Duration.newBuilder().setSeconds(2L).build()). setOperationName("HTTP GET /"). setStartTime(fromMillis(startTime)). addTags(componentTag). setFlags(1). addReferences(Model.SpanRef.newBuilder().setRefType(Model.SpanRefType.CHILD_OF).setSpanId(span1Id).setTraceId(traceId).build()). build(); Model.Span span3 = Model.Span.newBuilder(). setTraceId(trace2Id). setSpanId(span3Id). setDuration(Duration.newBuilder().setSeconds(3L).build()). setOperationName("HTTP GET /"). setStartTime(fromMillis(startTime)). setFlags(1). addReferences(Model.SpanRef.newBuilder().setRefType(Model.SpanRefType.CHILD_OF).setSpanId(span3ParentId).setTraceId(traceId).build()). build(); StreamObserver<Collector.PostSpansResponse> streamObserver = new StreamObserver<Collector.PostSpansResponse>() { @Override public void onNext(Collector.PostSpansResponse postSpansResponse) { } @Override public void onError(Throwable throwable) { } @Override public void onCompleted() { } }; Model.Batch testBatch = Model.Batch.newBuilder(). setProcess(Model.Process.newBuilder().setServiceName("frontend").addTags(ipTag).addTags(processLevelAppTag).build()). addAllSpans(ImmutableList.of(span1, span2)). build(); Collector.PostSpansRequest batches = Collector.PostSpansRequest.newBuilder().setBatch(testBatch).build(); handler.postSpans(batches, streamObserver); Model.Batch testBatchForProxyLevel = Model.Batch.newBuilder(). setProcess(Model.Process.newBuilder().setServiceName("frontend").addTags(ipTag).build()). addAllSpans(ImmutableList.of(span3)). build(); Collector.PostSpansRequest batchesForProxyLevel = Collector.PostSpansRequest.newBuilder().setBatch(testBatchForProxyLevel).build(); handler.postSpans(batchesForProxyLevel, streamObserver); verify(mockTraceHandler, mockTraceLogsHandler); }
@Override public void postSpans(Collector.PostSpansRequest request, StreamObserver<Collector.PostSpansResponse> responseObserver) { try { processBatch(request.getBatch(), 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 Protobuf batch processing failed", Throwables.getRootCause(e)); } responseObserver.onNext(Collector.PostSpansResponse.newBuilder().build()); responseObserver.onCompleted(); }
JaegerGrpcCollectorHandler extends CollectorServiceGrpc.CollectorServiceImplBase implements Runnable, Closeable { @Override public void postSpans(Collector.PostSpansRequest request, StreamObserver<Collector.PostSpansResponse> responseObserver) { try { processBatch(request.getBatch(), 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 Protobuf batch processing failed", Throwables.getRootCause(e)); } responseObserver.onNext(Collector.PostSpansResponse.newBuilder().build()); responseObserver.onCompleted(); } }
JaegerGrpcCollectorHandler extends CollectorServiceGrpc.CollectorServiceImplBase implements Runnable, Closeable { @Override public void postSpans(Collector.PostSpansRequest request, StreamObserver<Collector.PostSpansResponse> responseObserver) { try { processBatch(request.getBatch(), 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 Protobuf batch processing failed", Throwables.getRootCause(e)); } responseObserver.onNext(Collector.PostSpansResponse.newBuilder().build()); responseObserver.onCompleted(); } JaegerGrpcCollectorHandler(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);  JaegerGrpcCollectorHandler(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); }
JaegerGrpcCollectorHandler extends CollectorServiceGrpc.CollectorServiceImplBase implements Runnable, Closeable { @Override public void postSpans(Collector.PostSpansRequest request, StreamObserver<Collector.PostSpansResponse> responseObserver) { try { processBatch(request.getBatch(), 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 Protobuf batch processing failed", Throwables.getRootCause(e)); } responseObserver.onNext(Collector.PostSpansResponse.newBuilder().build()); responseObserver.onCompleted(); } JaegerGrpcCollectorHandler(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);  JaegerGrpcCollectorHandler(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 void postSpans(Collector.PostSpansRequest request,
                        StreamObserver<Collector.PostSpansResponse> responseObserver); @Override void run(); @Override void close(); }
JaegerGrpcCollectorHandler extends CollectorServiceGrpc.CollectorServiceImplBase implements Runnable, Closeable { @Override public void postSpans(Collector.PostSpansRequest request, StreamObserver<Collector.PostSpansResponse> responseObserver) { try { processBatch(request.getBatch(), 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 Protobuf batch processing failed", Throwables.getRootCause(e)); } responseObserver.onNext(Collector.PostSpansResponse.newBuilder().build()); responseObserver.onCompleted(); } JaegerGrpcCollectorHandler(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);  JaegerGrpcCollectorHandler(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 void postSpans(Collector.PostSpansRequest request,
                        StreamObserver<Collector.PostSpansResponse> responseObserver); @Override void run(); @Override void close();  }