RpcClientUtil.toTraceName(rpcRequest.toString()), parentSpanId); traceScope.detach();
@Override public void run() { TraceScope workerScope = tracer.newScope("workerSpan"); workerScope.detach(); scopeHolder.set(workerScope); } });
if (scope != null) { spanId = scope.getSpanId(); scope.detach(); one.setTraceScope(scope);
/** * Test calling detach() two times on a scope object. */ @Test public void TestDoubleDetachIsCaught() throws Exception { Tracer tracer = new Tracer.Builder(). name("TestDoubleDetach"). tracerPool(new TracerPool("TestDoubleDetachIsCaught")). conf(HTraceConfiguration. fromKeyValuePairs("sampler.classes", "AlwaysSampler")).build(); boolean gotException = false; TraceScope myScope = tracer.newScope("myScope"); myScope.detach(); try { myScope.detach(); } catch (RuntimeException e) { assertThat(e.getMessage(), containsString("it is already detached.")); gotException = true; } assertTrue("Expected to get exception because of double TraceScope " + "detach.", gotException); tracer.close(); }
/** * Test calling detach() two times on a scope object. */ @Test public void TestDoubleDetachOnNullScope() throws Exception { Tracer tracer = new Tracer.Builder(). name("TestDoubleDetachOnNullScope"). tracerPool(new TracerPool("TestDoubleDetachOnNullScope")). conf(HTraceConfiguration. fromKeyValuePairs("sampler.classes", "NeverSampler")).build(); boolean gotException = false; TraceScope myScope = tracer.newScope("myScope"); myScope.detach(); try { myScope.detach(); } catch (RuntimeException e) { assertThat(e.getMessage(), containsString("it is already detached.")); gotException = true; } assertTrue("Expected to get exception because of double TraceScope " + "detach on NullScope.", gotException); tracer.close(); }
private void verifyNullScope(TraceScope scope) { Assert.assertTrue(null == scope.getSpan()); Assert.assertFalse(scope.detached); scope.detach(); Assert.assertTrue(scope.detached); scope.reattach(); Assert.assertFalse(scope.detached); scope.close(); }
RpcClientUtil.toTraceName(rpcRequest.toString()), parentSpanId); traceScope.detach();
/** * Test calling reattach() two times on a scope object. */ @Test public void TestDoubleReattachIsCaught() throws Exception { Tracer tracer = new Tracer.Builder(). name("TestDoubleReattach"). tracerPool(new TracerPool("TestDoubleReattachIsCaught")). conf(HTraceConfiguration. fromKeyValuePairs("sampler.classes", "AlwaysSampler")).build(); boolean gotException = false; TraceScope myScope = tracer.newScope("myScope"); myScope.detach(); myScope.reattach(); try { myScope.reattach(); } catch (RuntimeException e) { assertThat(e.getMessage(), containsString("it is not detached.")); gotException = true; } assertTrue("Expected to get exception because of double TraceScope " + "reattach.", gotException); tracer.close(); }