org.apache.htrace.core.Tracer.close()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(151)

本文整理了Java中org.apache.htrace.core.Tracer.close()方法的一些代码示例,展示了Tracer.close()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tracer.close()方法的具体详情如下:
包路径:org.apache.htrace.core.Tracer
类名称:Tracer
方法名:close

Tracer.close介绍

暂无

代码示例

代码示例来源:origin: org.apache.hadoop/hadoop-common

@VisibleForTesting
public static synchronized void clear() {
 if (instance == null) {
  return;
 }
 try {
  instance.close();
 } finally {
  instance = null;
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

tracer.close();
return exitCode;

代码示例来源:origin: org.apache.hadoop/hadoop-hdfs

tracer.close();
tracer = null;

代码示例来源:origin: org.apache.hadoop/hadoop-hdfs

tracer.close();

代码示例来源:origin: org.apache.hadoop/hadoop-hdfs

tracer.close();

代码示例来源:origin: io.hops/hadoop-common

@VisibleForTesting
public static synchronized void clear() {
 if (instance == null) {
  return;
 }
 try {
  instance.close();
 } finally {
  instance = null;
 }
}

代码示例来源:origin: io.hops/hadoop-common

tracer.close();
return exitCode;

代码示例来源:origin: apache/incubator-htrace

Thread.sleep(10);
parent.close();
tracer.close();
System.out.println("trace id: " + traceid);

代码示例来源:origin: apache/incubator-htrace

private List<SpanReceiver> createSpanReceivers(String classes) {
 Tracer tracer = new Tracer.Builder().
   name("MyTracer").
   tracerPool(new TracerPool("createSpanReceivers")).
   conf(HTraceConfiguration.fromKeyValuePairs(
     "span.receiver.classes", classes)).
   build();
 SpanReceiver[] receivers = tracer.getTracerPool().getReceivers();
 tracer.close();
 LinkedList<SpanReceiver> receiverList = new LinkedList<SpanReceiver>();
 for (SpanReceiver item: receivers) {
  receiverList.add(item);
 }
 return receiverList;
}

代码示例来源:origin: apache/incubator-htrace

private Sampler[] getSamplersFromConf(HTraceConfiguration conf) {
 Tracer tracer = new Tracer.Builder().
   name("MyTracer").
   tracerPool(new TracerPool("getSamplersFromConf")).
   conf(conf).
   build();
 Sampler[] samplers = tracer.getSamplers();
 tracer.close();
 return samplers;
}

代码示例来源:origin: apache/incubator-htrace

@Test
 public void testWriteToLocalFile() throws IOException {
  String traceFileName = LocalFileSpanReceiver.getUniqueLocalTraceFileName();
  Tracer tracer = new Tracer.Builder().
    name("testWriteToLocalFileTracer").
    tracerPool(new TracerPool("testWriteToLocalFile")).
    conf(HTraceConfiguration.fromKeyValuePairs(
      "sampler.classes", "AlwaysSampler",
      "span.receiver.classes", LocalFileSpanReceiver.class.getName(),
      "local.file.span.receiver.path", traceFileName,
      "tracer.id", "%{tname}")).
    build();
  TraceScope scope = tracer.newScope("testWriteToLocalFile");
  scope.close();
  tracer.close();

  ObjectMapper mapper = new ObjectMapper();
  MilliSpan span = mapper.readValue(new File(traceFileName), MilliSpan.class);
  assertEquals("testWriteToLocalFile", span.getDescription());
  assertEquals("testWriteToLocalFileTracer", span.getTracerId());
 }
}

代码示例来源:origin: apache/incubator-htrace

traceCreator.createSimpleTrace();
traceCreator.createThreadedTrace();
tracer.close();
TraceGraph traceGraph = new TraceGraph(receiver.getSpans());
Collection<Span> roots = traceGraph.getSpansByParent().find(SpanId.INVALID);

代码示例来源:origin: apache/incubator-htrace

@Test
public void TestTracerCreateAndClose() throws Exception {
 Tracer tracer = new Tracer.Builder().
   name("TestSimpleScope").
   tracerPool(new TracerPool("TestTracerCreateAndClose")).
   conf(HTraceConfiguration.fromKeyValuePairs(
     "sampler.classes", "AlwaysSampler")).
   build();
 POJOSpanReceiver receiver =
   new POJOSpanReceiver(HTraceConfiguration.EMPTY);
 tracer.getTracerPool().addReceiver(receiver);
 tracer.close();
 Assert.assertTrue(receiver.getSpans().isEmpty());
}

代码示例来源:origin: apache/incubator-htrace

@Test
public void TestSimpleScope() throws Exception {
 Tracer tracer = new Tracer.Builder().
   name("TestSimpleScope").
   tracerPool(new TracerPool("TestSimpleScope")).
   conf(HTraceConfiguration.fromKeyValuePairs(
     "sampler.classes", "AlwaysSampler")).
   build();
 POJOSpanReceiver receiver =
   new POJOSpanReceiver(HTraceConfiguration.EMPTY);
 tracer.getTracerPool().addReceiver(receiver);
 TraceScope scope = tracer.newScope("Foo");
 scope.close();
 tracer.close();
 Assert.assertEquals(1, receiver.getSpans().size());
 Span span = receiver.getSpans().iterator().next();
 Assert.assertEquals(0, span.getParents().length);
}

代码示例来源:origin: apache/incubator-htrace

/**
 * 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();
}

代码示例来源:origin: apache/incubator-htrace

/**
 * 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();
}

代码示例来源:origin: apache/incubator-htrace

/**
 * 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();
}

代码示例来源:origin: apache/incubator-htrace

/**
 * 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();
}

代码示例来源:origin: apache/incubator-htrace

@Test(timeout=120000)
public void testSimpleTraces() throws IOException, InterruptedException {
 Tracer tracer = newTracer();
 Span rootSpan = new MilliSpan.Builder().
   description("root").
   spanId(new SpanId(100, 100)).
   tracerId("test").
   begin(System.currentTimeMillis()).
   build();
 TraceScope rootScope = tracer.newScope("root");
 TraceScope innerOne = tracer.newScope("innerOne");
 TraceScope innerTwo = tracer.newScope("innerTwo");
 innerTwo.close();
 Assert.assertTrue(flumeServer.nextEventBodyAsString().contains("innerTwo"));
 innerOne.close();
 Assert.assertTrue(flumeServer.nextEventBodyAsString().contains("innerOne"));
 rootSpan.addKVAnnotation("foo", "bar");
 rootSpan.addTimelineAnnotation("timeline");
 rootScope.close();
 Assert.assertTrue(flumeServer.nextEventBodyAsString().contains("root"));
 tracer.close();
}

代码示例来源:origin: apache/incubator-htrace

@Test
public void testSimpleTraces() throws IOException, InterruptedException {
 FakeZipkinTransport transport = new FakeZipkinTransport();
 Tracer tracer = newTracer(transport);
 Span rootSpan = new MilliSpan.Builder().
   description("root").
   spanId(new SpanId(100, 100)).
   tracerId("test").
   begin(System.currentTimeMillis()).
   build();
 TraceScope rootScope = tracer.newScope("root");
 TraceScope innerOne = tracer.newScope("innerOne");
 TraceScope innerTwo = tracer.newScope("innerTwo");
 innerTwo.close();
 Assert.assertTrue(transport.nextMessageAsSpan().getName().contains("innerTwo"));
 innerOne.close();
 Assert.assertTrue(transport.nextMessageAsSpan().getName().contains("innerOne"));
 rootSpan.addKVAnnotation("foo", "bar");
 rootSpan.addTimelineAnnotation("timeline");
 rootScope.close();
 Assert.assertTrue(transport.nextMessageAsSpan().getName().contains("root"));
 tracer.close();
}

相关文章