conf.getLong(DFSConfigKeys.DFS_NAMENODE_STALE_DATANODE_INTERVAL_KEY, DFSConfigKeys.DFS_NAMENODE_STALE_DATANODE_INTERVAL_DEFAULT); this.tracer = new Tracer.Builder("NamenodeFsck"). conf(TraceUtils.wrapHadoopConf("namenode.fsck.htrace.", conf)). build();
Table htable = createTable(UTIL); Configuration conf = UTIL.getConfiguration(); Tracer tracer = new Tracer.Builder(). name("testHBaseSpanReceiver"). tracerPool(new TracerPool("testHBaseSpanReceiver")). conf(HTraceConfiguration.fromKeyValuePairs( HBaseSpanReceiver.COLLECTOR_QUORUM_KEY, conf.get(HConstants.ZOOKEEPER_QUORUM), HBaseSpanReceiver.ZOOKEEPER_ZNODE_PARENT_KEY, conf.get(HConstants.ZOOKEEPER_ZNODE_PARENT) )).build(); TraceCreator tc = new TraceCreator(tracer); tc.createThreadedTrace();
Builder builder = new Tracer.Builder("TestTraceExecutor").conf(conf); try (Tracer tracer = builder.build()) { final ThreadFactory tf = new NamingThreadFactory(); ses = Executors.newScheduledThreadPool(TASK_COUNT, tf);
final Tracer tracer = new Tracer.Builder(). name("TestPassingSpanBetweenThreads"). tracerPool(new TracerPool("TestPassingSpanBetweenThreads")). conf(HTraceConfiguration. fromKeyValuePairs("sampler.classes", "AlwaysSampler")).build(); POJOSpanReceiver receiver = new POJOSpanReceiver(HTraceConfiguration.EMPTY);
); final Tracer tracer = new Tracer.Builder("test-tracer") .tracerPool(new TracerPool("test-tracer-pool")) .conf(hTraceConfiguration) .build();
@Test public void TestCreateSpans() throws Exception { Tracer tracer = new Tracer.Builder(). name("TestCreateSpans"). tracerPool(new TracerPool("TestCreateSpans")). conf(HTraceConfiguration.fromKeyValuePairs( "sampler.classes", "AlwaysSampler")). build(); POJOSpanReceiver receiver = new POJOSpanReceiver(HTraceConfiguration.EMPTY);
Tracer tracer = new Tracer.Builder(). conf(new HBaseHTraceConfiguration(HBaseConfiguration.create())). build(); tracer.addSampler(Sampler.ALWAYS); TraceScope parent = tracer.newScope("HBaseSpanReceiver.main.parent");
@Test public void testNewScopeWithParentID() throws Exception { Tracer tracer = new Tracer.Builder(). name("testNewScopeWithParentID"). tracerPool(new TracerPool("testNewScopeWithParentID")). conf(HTraceConfiguration.fromKeyValuePairs( "sampler.classes", "AlwaysSampler")).build(); TraceScope activeScope = tracer.newScope("CurrentActiveScope"); HashMap<Integer,SpanId> spanIdHashMap = new HashMap<>();
HTraceConfiguration conf = HTraceConfiguration.fromKeyValuePairs("sampler.classes", "AlwaysSampler"); ExecutorService es = null; try (Tracer tracer = new Tracer.Builder("TestTraceExecutor").conf(conf).build()) { es = Executors.newSingleThreadExecutor(new NamingThreadFactory()); es = tracer.newTraceExecutorService(es);
private void loadSamplers(List<Sampler> samplers) { String classNamesStr = conf.get(SAMPLER_CLASSES_KEY, ""); List<String> classNames = getClassNamesFromConf(classNamesStr); StringBuilder bld = new StringBuilder(); String prefix = ""; for (String className : classNames) { try { Sampler sampler = new Sampler.Builder(conf). className(className). classLoader(classLoader). build(); samplers.add(sampler); bld.append(prefix).append(className); prefix = ", "; } catch (Throwable e) { LOG.error("Failed to create Sampler of type " + className, e); } } String resultString = bld.toString(); if (resultString.isEmpty()) { resultString = "no samplers"; } LOG.debug(SAMPLER_CLASSES_KEY + " = " + classNamesStr + "; loaded " + resultString); }
private void loadSamplers(List<Sampler> samplers) { String classNamesStr = conf.get(SAMPLER_CLASSES_KEY, ""); List<String> classNames = getClassNamesFromConf(classNamesStr); StringBuilder bld = new StringBuilder(); String prefix = ""; for (String className : classNames) { try { Sampler sampler = new Sampler.Builder(conf). className(className). classLoader(classLoader). build(); samplers.add(sampler); bld.append(prefix).append(className); prefix = ", "; } catch (Throwable e) { LOG.error("Failed to create Sampler of type " + className, e); } } String resultString = bld.toString(); if (resultString.isEmpty()) { resultString = "no samplers"; } LOG.debug(SAMPLER_CLASSES_KEY + " = " + classNamesStr + "; loaded " + resultString); }
private void loadSamplers(List<Sampler> samplers) { String classNamesStr = conf.get(SAMPLER_CLASSES_KEY, ""); List<String> classNames = getClassNamesFromConf(classNamesStr); StringBuilder bld = new StringBuilder(); String prefix = ""; for (String className : classNames) { try { Sampler sampler = new Sampler.Builder(conf). className(className). classLoader(classLoader). build(); samplers.add(sampler); bld.append(prefix).append(className); prefix = ", "; } catch (Throwable e) { LOG.error("Failed to create SpanReceiver of type " + className, e); } } String resultString = bld.toString(); if (resultString.isEmpty()) { resultString = "no samplers"; } LOG.info(SAMPLER_CLASSES_KEY + " = " + classNamesStr + "; loaded " + resultString); }
/** * Test closing an outer scope when an inner one is still active. */ @Test public void TestClosingOuterScope() throws Exception { Tracer tracer = new Tracer.Builder(). name("TestClosingOuterScopeTracer"). tracerPool(new TracerPool("TestClosingOuterScope")). conf(HTraceConfiguration. fromKeyValuePairs("sampler.classes", "AlwaysSampler")).build(); boolean gotException = false; TraceScope outerScope = tracer.newScope("outer"); TraceScope innerScope = tracer.newScope("inner"); try { outerScope.close(); } catch (RuntimeException e) { assertThat(e.getMessage(), containsString("it is not the current TraceScope")); gotException = true; } assertTrue("Expected to get exception because of improper " + "scope closure.", gotException); innerScope.close(); 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(); }
/** * 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 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(); }
private void loadSpanReceivers() { String classNamesStr = conf.get(SPAN_RECEIVER_CLASSES_KEY, ""); List<String> classNames = getClassNamesFromConf(classNamesStr); StringBuilder bld = new StringBuilder(); String prefix = ""; for (String className : classNames) { try { tracerPool.loadReceiverType(className, conf, classLoader); bld.append(prefix).append(className); prefix = ", "; } catch (Throwable e) { LOG.error("Failed to create SpanReceiver of type " + className, e); } } String resultString = bld.toString(); if (resultString.isEmpty()) { resultString = "no span receivers"; } LOG.debug(SPAN_RECEIVER_CLASSES_KEY + " = " + classNamesStr + "; loaded " + resultString); }
@Test public void testWrappingFromSpan() throws Exception { HTraceConfiguration conf = HTraceConfiguration.fromKeyValuePairs("sampler.classes", "AlwaysSampler"); ExecutorService es = Executors.newSingleThreadExecutor(); try (Tracer tracer = new Tracer.Builder("TestTraceExecutor").conf(conf).build()) { SpanId random = SpanId.fromRandom(); try (TraceScope parentScope = tracer.newScope("parent")) { Callable<SpanId> callable = new TraceCallable<SpanId>(tracer, random, new Callable<SpanId>() { @Override public SpanId call() throws Exception { return Tracer.getCurrentSpan().getParents()[0]; } }, "child"); SpanId result = es.submit(callable).get(WAIT_TIME_SECONDS, TimeUnit.SECONDS); assertEquals(random, result); } } finally { es.shutdown(); } }
private void loadSpanReceivers() { String classNamesStr = conf.get(SPAN_RECEIVER_CLASSES_KEY, ""); List<String> classNames = getClassNamesFromConf(classNamesStr); StringBuilder bld = new StringBuilder(); String prefix = ""; for (String className : classNames) { try { tracerPool.loadReceiverType(className, conf, classLoader); bld.append(prefix).append(className); prefix = ", "; } catch (Throwable e) { LOG.error("Failed to create SpanReceiver of type " + className, e); } } String resultString = bld.toString(); if (resultString.isEmpty()) { resultString = "no span receivers"; } LOG.info(SPAN_RECEIVER_CLASSES_KEY + " = " + classNamesStr + "; loaded " + resultString); }
private void loadSpanReceivers() { String classNamesStr = conf.get(SPAN_RECEIVER_CLASSES_KEY, ""); List<String> classNames = getClassNamesFromConf(classNamesStr); StringBuilder bld = new StringBuilder(); String prefix = ""; for (String className : classNames) { try { tracerPool.loadReceiverType(className, conf, classLoader); bld.append(prefix).append(className); prefix = ", "; } catch (Throwable e) { LOG.error("Failed to create SpanReceiver of type " + className, e); } } String resultString = bld.toString(); if (resultString.isEmpty()) { resultString = "no span receivers"; } LOG.debug(SPAN_RECEIVER_CLASSES_KEY + " = " + classNamesStr + "; loaded " + resultString); }