gpt4 book ai didi

zipkin2.finagle.ZipkinTracer类的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 12:56:12 32 4
gpt4 key购买 nike

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

ZipkinTracer介绍

[英]Receives the Finagle generated traces and sends them off to Zipkin.

Implement this by extending and registering in the service loader. For example:

@AutoService(com.twitter.finagle.tracing.Tracer.class) 
public final class HttpZipkinTracer extends ZipkinTracer { 
--snip-- 
// Default constructor for the service loader 
public HttpZipkinTracer() { 
this(Config.builder().build(), 
DefaultStatsReceiver$.MODULE$.get().scope("zipkin.http") 
); 
} 
HttpZipkinTracer(Config config, StatsReceiver stats) { 
super(new HttpReporter(config.host()), stats, config.initialSampleRate()); 
} 
}

[中]接收欺骗生成的跟踪并将其发送给Zipkin。
通过在服务加载器中扩展和注册来实现这一点。例如:

@AutoService(com.twitter.finagle.tracing.Tracer.class) 
public final class HttpZipkinTracer extends ZipkinTracer { 
--snip-- 
// Default constructor for the service loader 
public HttpZipkinTracer() { 
this(Config.builder().build(), 
DefaultStatsReceiver$.MODULE$.get().scope("zipkin.http") 
); 
} 
HttpZipkinTracer(Config config, StatsReceiver stats) { 
super(new HttpReporter(config.host()), stats, config.initialSampleRate()); 
} 
}

代码示例

代码示例来源:origin: io.zipkin.finagle2/zipkin-finagle

@Override public Future<BoxedUnit> close(Duration after) {
 return close(after.fromNow());
}

代码示例来源:origin: openzipkin/zipkin-finagle

@Test
public void incrementsDropMetricsOnSendError() throws Exception {
 tracer.close();
 tracer = newTracer(FakeSender.create().onSpans(span -> {
  throw new IllegalStateException(new NullPointerException());
 }));
 tracer.record(new Record(root, Time.fromMilliseconds(TODAY), new ServiceName("web"), empty()));
 tracer.record(new Record(root, Time.fromMilliseconds(TODAY), new Rpc("get"), empty()));
 tracer.record(new Record(root, Time.fromMilliseconds(TODAY), ClientSend$.MODULE$, empty()));
 tracer.record(new Record(root, Time.fromMilliseconds(TODAY + 1), ClientRecv$.MODULE$, empty()));

代码示例来源:origin: openzipkin/zipkin-finagle

@Test public void unfinishedSpansArentImplicitlyReported() throws Exception {
 tracer.record(new Record(root, Time.fromMilliseconds(TODAY), new ServiceName("web"), empty()));
 tracer.record(new Record(root, Time.fromMilliseconds(TODAY), new Rpc("get"), empty()));
 tracer.record(new Record(root, Time.fromMilliseconds(TODAY), ClientSend$.MODULE$, empty()));
 tracer.reporter.flush();
 assertThat(spansSent.take()).isEmpty();
}

代码示例来源:origin: openzipkin/zipkin-finagle

ZipkinTracer newTracer(Sender sender) {
 return new ZipkinTracer(AsyncReporter.builder(sender)
   .messageTimeout(0, TimeUnit.MILLISECONDS)
   .messageMaxBytes(176 + 5) // size of a simple span w/ 128-bit trace ID + list overhead
   .metrics(new ReporterMetricsAdapter(stats))
   .build(), () -> 1.0f, stats);
}

代码示例来源:origin: openzipkin/zipkin-finagle

@Test public void finishedSpansAreImplicitlyReported() throws Exception {
 tracer.record(new Record(root, Time.fromMilliseconds(TODAY), new ServiceName("web"), empty()));
 tracer.record(new Record(root, Time.fromMilliseconds(TODAY), new Rpc("get"), empty()));
 tracer.record(new Record(root, Time.fromMilliseconds(TODAY), ClientSend$.MODULE$, empty()));
 // client receive reports the span
 tracer.record(new Record(root, Time.fromMilliseconds(TODAY + 1), ClientRecv$.MODULE$, empty()));
 tracer.reporter.flush();
 assertThat(spansSent.take().stream())
   .flatExtracting(Span::kind)
   .containsExactly(Span.Kind.CLIENT);
}

代码示例来源:origin: io.zipkin.finagle2/zipkin-finagle

@Override public Future<BoxedUnit> close() {
 return close(Time.Bottom());
}

代码示例来源:origin: openzipkin/zipkin-finagle

/** See {@link traceId128Bit$} */
@Test public void traceId128Bit() throws Exception {
  TraceId root = TraceId$.MODULE$.apply(
   SpanId.fromString("0f28590523a46541"),
   empty(),
   SpanId.fromString("0f28590523a46541").get(),
   empty(),
   Flags$.MODULE$.apply(),
   SpanId.fromString("d2f9288a2904503d"),
   false
 );
 tracer.record(new Record(root, Time.fromMilliseconds(TODAY), new ServiceName("web"), empty()));
 tracer.record(new Record(root, Time.fromMilliseconds(TODAY), new Rpc("get"), empty()));
 tracer.record(new Record(root, Time.fromMilliseconds(TODAY), ClientSend$.MODULE$, empty()));
 // client receive reports the span
 tracer.record(new Record(root, Time.fromMilliseconds(TODAY + 1), ClientRecv$.MODULE$, empty()));
 tracer.reporter.flush();
 assertThat(spansSent.take().stream())
   .extracting(Span::traceId)
   .containsExactly("d2f9288a2904503d0f28590523a46541");
}

代码示例来源:origin: openzipkin/zipkin-finagle

@Override public Future<BoxedUnit> close() {
 return close(Time.Bottom());
}

代码示例来源:origin: openzipkin/zipkin-finagle

@Test
public void reportIncrementsAcceptedMetrics() throws Exception {
 tracer.record(new Record(root, Time.fromMilliseconds(TODAY), new ServiceName("web"), empty()));
 tracer.record(new Record(root, Time.fromMilliseconds(TODAY), new Rpc("get"), empty()));
 tracer.record(new Record(root, Time.fromMilliseconds(TODAY), ClientSend$.MODULE$, empty()));
 tracer.record(new Record(root, Time.fromMilliseconds(TODAY + 1), ClientRecv$.MODULE$, empty()));
 tracer.reporter.flush();
 assertThat(mapAsJavaMap(stats.counters())).containsExactly(
   entry(seq("span_bytes"), 165L),
   entry(seq("spans"), 1L),
   entry(seq("spans_dropped"),0L),
   entry(seq("message_bytes"), 170L),
   entry(seq("messages"), 1L)
 );
}

代码示例来源:origin: openzipkin/zipkin-finagle

@Override public Future<BoxedUnit> close(Duration after) {
 return close(after.fromNow());
}

代码示例来源:origin: openzipkin/zipkin-finagle

@Test public void multipleSpansGoIntoSameMessage() throws Exception {
 tracer.record(new Record(FinagleTestObjects.root, Time.fromMilliseconds(FinagleTestObjects.TODAY), new ServiceName("web"), empty()));
 tracer.record(new Record(FinagleTestObjects.root, Time.fromMilliseconds(FinagleTestObjects.TODAY), new Rpc("get"), empty()));
 tracer.record(new Record(FinagleTestObjects.root, Time.fromMilliseconds(FinagleTestObjects.TODAY), ServerRecv$.MODULE$, empty()));
 tracer.record(new Record(
   FinagleTestObjects.root, Time.fromMilliseconds(FinagleTestObjects.TODAY + 1), ServerSend$.MODULE$, empty()));
 tracer.record(new Record(
   FinagleTestObjects.child, Time.fromMilliseconds(FinagleTestObjects.TODAY), new ServiceName("web"), empty()));
 tracer.record(new Record(
   FinagleTestObjects.child, Time.fromMilliseconds(FinagleTestObjects.TODAY), new Rpc("get"), empty()));
 tracer.record(new Record(
          FinagleTestObjects.child, Time.fromMilliseconds(FinagleTestObjects.TODAY), ClientSend$.MODULE$, empty()));
 tracer.record(new Record(
   FinagleTestObjects.child, Time.fromMilliseconds(FinagleTestObjects.TODAY + 1), ClientRecv$.MODULE$, empty()));

代码示例来源:origin: openzipkin/zipkin-finagle

@After
public void closeTracer() throws Exception {
 tracer.close();
}

代码示例来源:origin: openzipkin/zipkin-finagle

@After
public void closeTracer() {
 tracer.close();
 stats.clear();
}

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com