本文整理汇总了Java中zipkin.reporter.AsyncReporter类的典型用法代码示例。如果您正苦于以下问题:Java AsyncReporter类的具体用法?Java AsyncReporter怎么用?Java AsyncReporter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AsyncReporter类属于zipkin.reporter包,在下文中一共展示了AsyncReporter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createZipkin
import zipkin.reporter.AsyncReporter; //导入依赖的package包/类
public static Tuple<Tracing, Flushable> createZipkin(String serviceName, String collectorUrl) {
Sender sender = OkHttpSender.builder()
.endpoint(collectorUrl + "/api/v1/spans")
.encoding(Encoding.JSON)
.build();
AsyncReporter<Span> reporter = AsyncReporter.builder(sender)
.closeTimeout(1, TimeUnit.MILLISECONDS)
.build();
return new Tuple<>(Tracing.newBuilder()
.localServiceName(serviceName)
.sampler(Sampler.ALWAYS_SAMPLE)
.traceId128Bit(true)
.reporter(reporter)
.build(), () -> reporter.flush());
}
示例2: getZipkinReporterBuilder
import zipkin.reporter.AsyncReporter; //导入依赖的package包/类
protected AsyncReporter.Builder getZipkinReporterBuilder(StagemonitorPlugin.InitArguments initArguments) {
final ZipkinPlugin zipkinPlugin = initArguments.getPlugin(ZipkinPlugin.class);
final AsyncReporter.Builder reporterBuilder = AsyncReporter
.builder(getSender(zipkinPlugin))
.messageTimeout(zipkinPlugin.getZipkinFlushInterval(), TimeUnit.MILLISECONDS);
final Integer zipkinMaxQueuedBytes = zipkinPlugin.getZipkinMaxQueuedBytes();
if (zipkinMaxQueuedBytes != null) {
reporterBuilder.queuedMaxBytes(zipkinMaxQueuedBytes);
}
if (initArguments.getPlugin(CorePlugin.class).isInternalMonitoringActive()) {
reporterBuilder.metrics(new StagemonitorReporterMetrics(initArguments.getMetricRegistry()));
}
return reporterBuilder;
}
示例3: main
import zipkin.reporter.AsyncReporter; //导入依赖的package包/类
public static void main(String[] args) {
// Configure a reporter, which controls how often spans are sent
// (the dependency is io.zipkin.reporter:zipkin-sender-okhttp3)
OkHttpSender sender = OkHttpSender.create("http://127.0.0.1:9411/api/v1/spans");
AsyncReporter reporter = AsyncReporter.create(sender);
// Create a tracing component with the service name you want to see in Zipkin.
Tracing tracing = Tracing.newBuilder()
.localServiceName("my-service")
.reporter(reporter)
.build();
// Tracing exposes objects you might need, most importantly the tracer
Tracer tracer = tracing.tracer();
Span span = tracer.newTrace().name("encode").start();
try {
//doSomethingExpensive();
} finally {
span.finish();
}
// When all tracing tasks are complete, close the tracing component and reporter
// This might be a shutdown hook for some users
tracing.close();
reporter.close();
}
示例4: OpentracingZipkinTracer
import zipkin.reporter.AsyncReporter; //导入依赖的package包/类
/**
* Creates and returns a tracer that is uses
* a serviceName and the location of a zipkin host/port
* to provide tracing capability.
*
* @param serviceName
* @param config
*/
public OpentracingZipkinTracer(String serviceName, Config config) {
String traceServiceUrl = "http://"+config.host()+":"+config.port()+"/api/v1/spans";
OkHttpSender.Builder senderBuilder = OkHttpSender.builder().endpoint(traceServiceUrl).compressionEnabled(config.compress());
if (config.maxRequests() != Integer.MIN_VALUE) {
senderBuilder.maxRequests(config.maxRequests());
}
if (config.encoding() != null) {
senderBuilder.encoding(config.encoding());
}
if (config.maxMessageSize() != Integer.MIN_VALUE) {
senderBuilder.messageMaxBytes(config.maxMessageSize());
}
Sender sender = senderBuilder.build();
AsyncReporter.Builder reporterBuilder = AsyncReporter.builder(sender);
if (config.closeTimeout() != Integer.MIN_VALUE) {
reporterBuilder.closeTimeout(config.closeTimeout(), TimeUnit.SECONDS);
}
if (config.messageTimeout() != Integer.MIN_VALUE) {
reporterBuilder.messageTimeout(config.messageTimeout(), TimeUnit.SECONDS);
}
if (config.queuedMaxBytes() != Integer.MIN_VALUE) {
reporterBuilder.queuedMaxBytes(config.queuedMaxBytes());
}
if (config.queuedMaxSpans() != Integer.MIN_VALUE) {
reporterBuilder.queuedMaxSpans(config.queuedMaxSpans());
}
Reporter<zipkin.Span> reporter = reporterBuilder.build();
Tracing braveTracing = Tracing.newBuilder()
.localServiceName(serviceName)
.reporter(reporter)
.build();
tracer = BraveTracer.create(braveTracing);
}
示例5: activate
import zipkin.reporter.AsyncReporter; //导入依赖的package包/类
@Activate
public void activate(BundleContext context) {
URLConnectionSender sender = URLConnectionSender.builder()
.endpoint("http://localhost:9411/api/v1/spans").build();
//KafkaSender sender = KafkaSender.builder().bootstrapServers("kafka:9092").build();
reporter = AsyncReporter.builder(sender).build();
Brave brave = create();
reg = context.registerService(Brave.class, brave, null);
}
示例6: activate
import zipkin.reporter.AsyncReporter; //导入依赖的package包/类
@Activate
public void activate(Config config, BundleContext context, Map<String,String> properties) {
URLConnectionSender sender = URLConnectionSender.builder()
.endpoint(config.endpoint()) //
.compressionEnabled(config.compressionEnabled()) //
.connectTimeout(config.connectTimeout())
.messageMaxBytes(config.messageMaxBytes())
.build();
reporter = AsyncReporter.builder(sender).build();
reg = context.registerService(Reporter.class, reporter, new Hashtable<String, String>(properties));
}
示例7: activate
import zipkin.reporter.AsyncReporter; //导入依赖的package包/类
@Activate
public void activate(Config config, BundleContext context, Map<String, String> properties) {
this.context = context;
OkHttpSender sender = createSender(config, properties);
reporter = AsyncReporter.create(sender);
reporterServiceRegistration = context.registerService(Reporter.class, reporter,
new Hashtable<String, String>(properties));
tracing = httpTracer(config, properties, reporter);
tracingServiceRegistration = context.registerService(Tracing.class, tracing,
new Hashtable<String, String>(properties));
}
示例8: newTracer
import zipkin.reporter.AsyncReporter; //导入依赖的package包/类
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);
}
示例9: brave
import zipkin.reporter.AsyncReporter; //导入依赖的package包/类
public static Brave brave(String serviceName) {
return new Brave.Builder(serviceName)
.traceSampler(Sampler.ALWAYS_SAMPLE)
.reporter(AsyncReporter.builder(URLConnectionSender.builder()
.endpoint("http://docker-machine.dev:8080/api/v1/spans")
.build()).build())
.build();
}
示例10: getBraveInstance
import zipkin.reporter.AsyncReporter; //导入依赖的package包/类
public Brave getBraveInstance() {
Brave.Builder builder = new Brave.Builder(name.get());
if (this.url.isDefault()) {
builder.reporter(new LoggingReporter())
.traceSampler(Sampler.create(1.0f));
} else {
AsyncReporter<Span> asyncReporter = AsyncReporter.builder(URLConnectionSender.create(url.get())).build();
builder.reporter(asyncReporter)
.traceSampler(Sampler.create(rate.get()));
}
return builder.build();
}
示例11: getBrave
import zipkin.reporter.AsyncReporter; //导入依赖的package包/类
@Produces
@Singleton
public Brave getBrave() {
String port = System.getenv("TRACING_PORT");
if (port == null) {
throw new IllegalStateException("Environmental variable TRACING_PORT is not set!");
}
return new Brave.Builder("wildfly-swarm")
.reporter(AsyncReporter.builder(OkHttpSender.builder()
.endpoint("http://tracing-server:" + port + "/api/v1/spans")
.build())
.build())
.build();
}
示例12: createZipkinTracer
import zipkin.reporter.AsyncReporter; //导入依赖的package包/类
protected Tracing createZipkinTracer(String serviceName) {
return Tracing.newBuilder()
.localServiceName(serviceName)
.reporter(AsyncReporter.builder(OkHttpSender.create(zipkinUrl + "api/v1/spans"))
.build()).build();
}
示例13: reporter
import zipkin.reporter.AsyncReporter; //导入依赖的package包/类
@Bean
Reporter<Span> reporter() {
// return new LoggingReporter(); // logs spans to console
return AsyncReporter.builder(sender()).build(); // sends spans to zipkin
}
示例14: reporter
import zipkin.reporter.AsyncReporter; //导入依赖的package包/类
/** Configuration for how to buffer spans into messages for Zipkin */
@Bean Reporter<Span> reporter() {
// return new LoggingReporter();
return AsyncReporter.builder(sender()).build(); // Sends to Zipkin
}
示例15: activate
import zipkin.reporter.AsyncReporter; //导入依赖的package包/类
@Activate
public void activate(Config config, BundleContext context, Map<String,String> properties) {
KafkaSender sender = createSender(config, properties);
reporter = AsyncReporter.builder(sender).build();
reg = context.registerService(Reporter.class, reporter, new Hashtable<String, String>(properties));
}