本文整理了Java中zipkin2.finagle.ZipkinTracer
类的一些代码示例,展示了ZipkinTracer
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipkinTracer
类的具体详情如下:
包路径:zipkin2.finagle.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();
}
内容来源于网络,如有侵权,请联系作者删除!