本文整理汇总了Java中zipkin2.reporter.AsyncReporter类的典型用法代码示例。如果您正苦于以下问题:Java AsyncReporter类的具体用法?Java AsyncReporter怎么用?Java AsyncReporter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AsyncReporter类属于zipkin2.reporter包,在下文中一共展示了AsyncReporter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ZipkinTracerFactory
import zipkin2.reporter.AsyncReporter; //导入依赖的package包/类
public ZipkinTracerFactory() {
JbootOpentracingConfig config = Jboot.config(JbootOpentracingConfig.class);
URLConnectionSender sender = URLConnectionSender.newBuilder()
.endpoint(config.getUrl())
.connectTimeout(config.getConnectTimeout())
.compressionEnabled(config.isCompressionEnabled())
.readTimeout(config.getReadTimeout())
.build();
AsyncReporter<Span> reporter = AsyncReporter.builder(sender)
.build();
Tracing tracing = Tracing.newBuilder()
.spanReporter(reporter)
.localServiceName(config.getServiceName())
.build();
tracer = BraveTracer.newBuilder(tracing).build();
}
示例2: getZipkinTracer
import zipkin2.reporter.AsyncReporter; //导入依赖的package包/类
static Tracer getZipkinTracer(String serviceName) {
try {
// Configure a reporter, which controls how often spans are sent
// (the dependency is io.zipkin.reporter2:zipkin-sender-okhttp3)
final OkHttpSender sender = OkHttpSender.create("http://docker-vm:9411/api/v2/spans");
final AsyncReporter<Span> spanReporter = AsyncReporter.create(sender);
// Now, create a Brave tracing component with the service name you want to see in Zipkin.
// (the dependency is io.zipkin.brave:brave)
final Tracing braveTracing =
Tracing.newBuilder()
.localServiceName(serviceName)
.spanReporter(spanReporter)
.build();
// use this to create an OpenTracing Tracer
return BraveTracer.create(braveTracing);
} catch (Exception e) {
e.printStackTrace();
return NoopTracerFactory.create();
}
}
示例3: build
import zipkin2.reporter.AsyncReporter; //导入依赖的package包/类
/**
* Build a new {@link HttpTracing} instance for interfacing with Zipkin
*
* @param environment
* Environment
* @return Brave instance
*/
@Override
public Optional<HttpTracing> build(@Nonnull final Environment environment) {
if (!isEnabled()) {
LOGGER.warn("Zipkin tracing is disabled");
return Optional.empty();
}
final ReporterMetrics metricsHandler = new DropwizardReporterMetrics(
environment.metrics());
final KafkaSender sender = KafkaSender.newBuilder()
.bootstrapServers(bootstrapServers).topic(topic).build();
final AsyncReporter<Span> reporter = AsyncReporter.builder(sender)
.metrics(metricsHandler).build();
environment.lifecycle().manage(new ReporterManager(reporter, sender));
LOGGER.info("Sending spans to Kafka topic \"{}\" at: {}", topic,
bootstrapServers);
return buildTracing(environment, reporter);
}
示例4: build
import zipkin2.reporter.AsyncReporter; //导入依赖的package包/类
/**
* Build a new {@link HttpTracing} instance for interfacing with Zipkin
*
* @param environment
* Environment
* @return HttpTracing instance
*/
@Override
public Optional<HttpTracing> build(@Nonnull final Environment environment) {
if (!isEnabled()) {
LOGGER.warn("Zipkin tracing is disabled");
return Optional.empty();
}
final ReporterMetrics metricsHandler = new DropwizardReporterMetrics(
environment.metrics());
final URLConnectionSender sender = URLConnectionSender
.create(URI.create(baseUrl).resolve("api/v2/spans").toString());
final AsyncReporter<Span> reporter = AsyncReporter.builder(sender)
.metrics(metricsHandler).build();
environment.lifecycle().manage(new ReporterManager(reporter, sender));
LOGGER.info("Sending spans to HTTP collector at: {}", baseUrl);
return buildTracing(environment, reporter);
}
示例5: metrics
import zipkin2.reporter.AsyncReporter; //导入依赖的package包/类
@Test public void metrics() {
context = new XmlBeans(""
+ "<bean id=\"asyncReporter\" class=\"zipkin2.reporter.beans.AsyncReporterFactoryBean\">\n"
+ " <property name=\"sender\">\n"
+ " <util:constant static-field=\"" + getClass().getName() + ".SENDER\"/>\n"
+ " </property>\n"
+ " <property name=\"metrics\">\n"
+ " <util:constant static-field=\"" + getClass().getName() + ".METRICS\"/>\n"
+ " </property>\n"
+ "</bean>"
);
assertThat(context.getBean("asyncReporter", AsyncReporter.class))
.extracting("metrics")
.containsExactly(METRICS);
}
示例6: zipkinReporter
import zipkin2.reporter.AsyncReporter; //导入依赖的package包/类
@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();
}
示例7: Tracing
import zipkin2.reporter.AsyncReporter; //导入依赖的package包/类
public Tracing() {
String endpoint = System.getProperty("zipkin.http_endpoint");
if (endpoint == null) {
component = new TracingComponent.Current();
return;
}
AsyncReporter<zipkin2.Span> spanReporter =
AsyncReporter.builder(URLConnectionSender.create(endpoint))
.build(endpoint.contains("v2") ? SpanBytesEncoder.JSON_V2 : SpanBytesEncoder.JSON_V1);
brave.Tracing tracing = brave.Tracing.newBuilder()
.localServiceName(System.getProperty("zipkin.service_name", "cassandra"))
.spanReporter(spanReporter).build();
component = new TracingComponent.Explicit(tracing);
}
示例8: build
import zipkin2.reporter.AsyncReporter; //导入依赖的package包/类
/**
* Build a new {@link HttpTracing} instance for interfacing with Zipkin
*
* @param environment
* Environment
* @return Brave instance
*/
@Override
public Optional<HttpTracing> build(@Nonnull final Environment environment) {
if (!isEnabled()) {
LOGGER.warn("Zipkin tracing is disabled");
return Optional.empty();
}
final ReporterMetrics metricsHandler = new DropwizardReporterMetrics(
environment.metrics());
final RabbitMQSender sender = RabbitMQSender.newBuilder()
.addresses(addresses).queue(queue)
.connectionTimeout((int) connectionTimeout.toMilliseconds())
.username(username).password(password).virtualHost(virtualHost)
.build();
final AsyncReporter<Span> reporter = AsyncReporter.builder(sender)
.metrics(metricsHandler).build();
environment.lifecycle().manage(new ReporterManager(reporter, sender));
LOGGER.info("Sending spans to RabbitMQ queue \"{}\" at: {}", queue,
addresses);
return buildTracing(environment, reporter);
}
示例9: createInstance
import zipkin2.reporter.AsyncReporter; //导入依赖的package包/类
@Override protected AsyncReporter createInstance() throws Exception {
AsyncReporter.Builder builder = AsyncReporter.builder(sender);
if (metrics != null) builder.metrics(metrics);
if (messageMaxBytes != null) builder.messageMaxBytes(messageMaxBytes);
if (messageTimeout != null) builder.messageTimeout(messageTimeout, TimeUnit.MILLISECONDS);
if (closeTimeout != null) builder.closeTimeout(closeTimeout, TimeUnit.MILLISECONDS);
if (queuedMaxSpans != null) builder.queuedMaxSpans(queuedMaxSpans);
if (queuedMaxBytes != null) builder.queuedMaxBytes(queuedMaxBytes);
return builder.build(encoder);
}
示例10: sender
import zipkin2.reporter.AsyncReporter; //导入依赖的package包/类
@Test public void sender() {
context = new XmlBeans(""
+ "<bean id=\"asyncReporter\" class=\"zipkin2.reporter.beans.AsyncReporterFactoryBean\">\n"
+ " <property name=\"sender\">\n"
+ " <util:constant static-field=\"" + getClass().getName() + ".SENDER\"/>\n"
+ " </property>\n"
+ "</bean>"
);
assertThat(context.getBean("asyncReporter", AsyncReporter.class))
.extracting("sender")
.containsExactly(SENDER);
}
示例11: messageMaxBytes
import zipkin2.reporter.AsyncReporter; //导入依赖的package包/类
@Test public void messageMaxBytes() {
context = new XmlBeans(""
+ "<bean id=\"asyncReporter\" class=\"zipkin2.reporter.beans.AsyncReporterFactoryBean\">\n"
+ " <property name=\"sender\">\n"
+ " <util:constant static-field=\"" + getClass().getName() + ".SENDER\"/>\n"
+ " </property>\n"
+ " <property name=\"messageMaxBytes\" value=\"512\"/>\n"
+ "</bean>"
);
assertThat(context.getBean("asyncReporter", AsyncReporter.class))
.extracting("messageMaxBytes")
.containsExactly(512);
}
示例12: messageTimeout
import zipkin2.reporter.AsyncReporter; //导入依赖的package包/类
@Test public void messageTimeout() {
context = new XmlBeans(""
+ "<bean id=\"asyncReporter\" class=\"zipkin2.reporter.beans.AsyncReporterFactoryBean\">\n"
+ " <property name=\"sender\">\n"
+ " <util:constant static-field=\"" + getClass().getName() + ".SENDER\"/>\n"
+ " </property>\n"
+ " <property name=\"messageTimeout\" value=\"500\"/>\n"
+ "</bean>"
);
assertThat(context.getBean("asyncReporter", AsyncReporter.class))
.extracting("messageTimeoutNanos")
.containsExactly(TimeUnit.MILLISECONDS.toNanos(500));
}
示例13: closeTimeout
import zipkin2.reporter.AsyncReporter; //导入依赖的package包/类
@Test public void closeTimeout() {
context = new XmlBeans(""
+ "<bean id=\"asyncReporter\" class=\"zipkin2.reporter.beans.AsyncReporterFactoryBean\">\n"
+ " <property name=\"sender\">\n"
+ " <util:constant static-field=\"" + getClass().getName() + ".SENDER\"/>\n"
+ " </property>\n"
+ " <property name=\"closeTimeout\" value=\"500\"/>\n"
+ "</bean>"
);
assertThat(context.getBean("asyncReporter", AsyncReporter.class))
.extracting("closeTimeoutNanos")
.containsExactly(TimeUnit.MILLISECONDS.toNanos(500));
}
示例14: queuedMaxSpans
import zipkin2.reporter.AsyncReporter; //导入依赖的package包/类
@Test public void queuedMaxSpans() {
context = new XmlBeans(""
+ "<bean id=\"asyncReporter\" class=\"zipkin2.reporter.beans.AsyncReporterFactoryBean\">\n"
+ " <property name=\"sender\">\n"
+ " <util:constant static-field=\"" + getClass().getName() + ".SENDER\"/>\n"
+ " </property>\n"
+ " <property name=\"queuedMaxSpans\" value=\"10\"/>\n"
+ "</bean>"
);
assertThat(context.getBean("asyncReporter", AsyncReporter.class))
.extracting("pending.maxSize")
.containsExactly(10);
}
示例15: queuedMaxBytes
import zipkin2.reporter.AsyncReporter; //导入依赖的package包/类
@Test public void queuedMaxBytes() {
context = new XmlBeans(""
+ "<bean id=\"asyncReporter\" class=\"zipkin2.reporter.beans.AsyncReporterFactoryBean\">\n"
+ " <property name=\"sender\">\n"
+ " <util:constant static-field=\"" + getClass().getName() + ".SENDER\"/>\n"
+ " </property>\n"
+ " <property name=\"queuedMaxBytes\" value=\"512\"/>\n"
+ "</bean>"
);
assertThat(context.getBean("asyncReporter", AsyncReporter.class))
.extracting("pending.maxBytes")
.containsExactly(512);
}