本文整理了Java中zipkin2.reporter.AsyncReporter
类的一些代码示例,展示了AsyncReporter
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AsyncReporter
类的具体详情如下:
包路径:zipkin2.reporter.AsyncReporter
类名称:AsyncReporter
[英]As spans are reported, they are encoded and added to a pending queue. The task of sending spans happens on a separate thread which calls #flush(). By doing so, callers are protected from latency or exceptions possible when exporting spans out of process.
Spans are bundled into messages based on size in bytes or a timeout, whichever happens first.
The thread that sends flushes spans to the Sender does so in a synchronous loop. This means that even asynchronous transports will wait for an ack before sending a next message. We do this so that a surge of spans doesn't overrun memory or bandwidth via hundreds or thousands of in-flight messages. The downside of this is that reporting is limited in speed to what a single thread can clear. When a thread cannot clear the backlog, new spans are dropped.
[中]报告跨距时,会对跨距进行编码并将其添加到挂起队列中。发送跨度的任务发生在调用#flush()的单独线程上。通过这样做,调用方可以避免在进程外导出跨度时可能出现的延迟或异常。
跨度根据字节大小或超时(以先发生的为准)绑定到消息中。
向发送方发送刷新跨度的线程在同步循环中执行此操作。这意味着即使是异步传输也会在发送下一条消息之前等待ack。我们这样做的目的是,跨度的激增不会通过成百上千条飞行中的消息而超出内存或带宽。这样做的缺点是,报告的速度限制在单个线程可以清除的范围内。当线程无法清除积压工作时,会删除新的跨度。
代码示例来源:origin: spring-cloud/spring-cloud-sleuth
/**
* Reporter that is depending on a {@link Sender} bean which is created in another
* auto-configuration than {@link ZipkinAutoConfiguration}.
*/
@Bean
@Conditional(BackwardsCompatibilityCondition.class)
@Deprecated
Reporter<Span> reporter(ReporterMetrics reporterMetrics, ZipkinProperties zipkin,
BytesEncoder<Span> spanBytesEncoder, DefaultListableBeanFactory beanFactory) {
List<String> beanNames = new ArrayList<>(
Arrays.asList(beanFactory.getBeanNamesForType(Sender.class)));
beanNames.remove(ZipkinAutoConfiguration.SENDER_BEAN_NAME);
Sender sender = (Sender) beanFactory.getBean(beanNames.get(0));
// historical constraint. Note: AsyncReporter supports memory bounds
return AsyncReporter.builder(sender).queuedMaxSpans(1000)
.messageTimeout(zipkin.getMessageTimeout(), TimeUnit.SECONDS)
.metrics(reporterMetrics).build(spanBytesEncoder);
}
代码示例来源:origin: openzipkin/brave
public Traced() {
super(Tracing.newBuilder()
.spanReporter(AsyncReporter.create(new NoopSender()))
.build());
}
}
代码示例来源:origin: vmware/xenon
if (zipkinUrl.contains("/v1/")) {
sender = URLConnectionSender.create(zipkinUrl);
spanReporter = AsyncReporter.builder(sender)
.build(SpanBytesEncoder.JSON_V1);
} else {
sender = OkHttpSender.create(zipkinUrl);
spanReporter = AsyncReporter.create(sender);
代码示例来源:origin: com.alipay.sofa/tracer-sofa-boot-starter
@Override
public void close() {
this.delegate.close();
}
代码示例来源:origin: alipay/sofa-tracer
@Override
public void flush() {
this.delegate.flush();
}
代码示例来源:origin: com.alipay.sofa/sofa-tracer-zipkin-plugin
@Override
public void close() {
this.delegate.close();
}
代码示例来源:origin: com.alipay.sofa/tracer-sofa-boot-starter
@Override
public void flush() throws IOException {
this.delegate.flush();
}
代码示例来源:origin: spring-cloud/spring-cloud-sleuth
@Bean(REPORTER_BEAN_NAME)
@ConditionalOnMissingBean(name = REPORTER_BEAN_NAME)
public Reporter<Span> reporter(ReporterMetrics reporterMetrics,
ZipkinProperties zipkin, @Qualifier(SENDER_BEAN_NAME) Sender sender) {
// historical constraint. Note: AsyncReporter supports memory bounds
return AsyncReporter.builder(sender).queuedMaxSpans(1000)
.messageTimeout(zipkin.getMessageTimeout(), TimeUnit.SECONDS)
.metrics(reporterMetrics).build(zipkin.getEncoder());
}
代码示例来源:origin: openzipkin/brave
public Traced128() {
super(Tracing.newBuilder()
.traceId128Bit(true)
.spanReporter(AsyncReporter.create(new NoopSender()))
.build());
}
}
代码示例来源:origin: alipay/sofa-tracer
@Override
public void close() {
this.delegate.close();
}
代码示例来源:origin: com.alipay.sofa/sofa-tracer-zipkin-plugin
@Override
public void flush() {
this.delegate.flush();
}
代码示例来源:origin: oracle/helidon
Reporter<Span> reporter = AsyncReporter.builder(buildSender)
.build(version.encoder());
代码示例来源:origin: openzipkin/brave
public Unsampled() {
super(Tracing.newBuilder()
.sampler(Sampler.NEVER_SAMPLE)
.spanReporter(AsyncReporter.create(new NoopSender()))
.build());
}
}
代码示例来源:origin: com.smoketurner.dropwizard/zipkin-core
@Override
public void stop() throws Exception {
// the reporter needs to be closed first so that it can report on
// any dropped spans before closing the sender connection.
reporter.close();
sender.close();
}
}
代码示例来源: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: apache/servicecomb-java-chassis
@Bean
Reporter<Span> zipkinReporter(Sender sender) {
if (apiVersion.compareTo(CONFIG_TRACING_COLLECTOR_API_V1) == 0) {
return AsyncReporter.builder(sender).build(SpanBytesEncoder.JSON_V1);
}
return AsyncReporter.builder(sender).build();
}
代码示例来源:origin: openzipkin/brave
public TracedExtra() {
super(Tracing.newBuilder()
.propagationFactory(ExtraFieldPropagation.newFactoryBuilder(B3Propagation.FACTORY)
.addField("x-vcap-request-id")
.addPrefixedFields("baggage-", Arrays.asList("country-code", "user-id"))
.build()
)
.spanReporter(AsyncReporter.create(new NoopSender()))
.build());
}
}
代码示例来源:origin: io.zipkin.finagle2/zipkin-finagle
@Override public Future<BoxedUnit> close(Time deadline) {
reporter.close();
return underlying.recorder.close(deadline);
}
代码示例来源: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: org.apache.servicecomb/handler-tracing-zipkin
@Bean
Reporter<Span> zipkinReporter(Sender sender) {
if (apiVersion.compareTo(CONFIG_TRACING_COLLECTOR_API_V1) == 0) {
return AsyncReporter.builder(sender).build(SpanBytesEncoder.JSON_V1);
}
return AsyncReporter.builder(sender).build();
}
内容来源于网络,如有侵权,请联系作者删除!