AbstractExternalRequest extends MonitoredRequest { @Override public Span createSpan() { final Tracer.SpanBuilder spanBuilder; final Span activeSpan = tracer.scopeManager().activeSpan(); if (activeSpan != null) { spanBuilder = tracer.buildSpan(operationName) .withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT); } else { spanBuilder = tracer.buildSpan(operationName) .withTag(Tags.SAMPLING_PRIORITY.getKey(), 0) .withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT); } if (trackMetricsPerOperationName()) { spanBuilder.withTag(MetricsSpanEventListener.ENABLE_TRACKING_METRICS_TAG, true); } spanBuilder.withTag(SpanUtils.OPERATION_TYPE, getType()); return spanBuilder.start(); } protected  AbstractExternalRequest(Tracer tracer);  AbstractExternalRequest(Tracer tracer, String operationName); @Override Span createSpan(); @Override void execute(); static final String EXTERNAL_REQUEST_METHOD; }
@Test public void testDontMonitorClientRootSpans() throws Exception { MockTracer tracer = new MockTracer(); new AbstractExternalRequest(tracer) { @Override protected String getType() { return "jdbc"; } }.createSpan().finish(); assertThat(tracer.finishedSpans().get(0).tags().get(Tags.SAMPLING_PRIORITY.getKey())).isEqualTo(0); }