zipkin2.reporter.AsyncReporter.builder()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(177)

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

AsyncReporter.builder介绍

[英]Like #create(Sender), except you can configure settings such as the timeout.
[中]与#create(Sender)类似,只是您可以配置超时等设置。

代码示例

代码示例来源: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: 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: oracle/helidon

Reporter<Span> reporter = AsyncReporter.builder(buildSender)
    .build(version.encoder());

代码示例来源: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: 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();
}

代码示例来源:origin: no.difi.oxalis/oxalis-commons

@Provides
@Singleton
@Named("http")
protected Reporter getHttpReporter(Settings<BraveConf> settings) {
  return AsyncReporter
      .builder(URLConnectionSender.create(settings.getString(BraveConf.HTTP)))
      .build();
}

代码示例来源:origin: difi/oxalis

@Provides
@Singleton
@Named("http")
protected Reporter getHttpReporter(Settings<BraveConf> settings) {
  return AsyncReporter
      .builder(URLConnectionSender.create(settings.getString(BraveConf.HTTP)))
      .build();
}

代码示例来源:origin: spring-cloud/spring-cloud-gcp

@Bean(REPORTER_BEAN_NAME)
@ConditionalOnMissingBean(name = REPORTER_BEAN_NAME)
public Reporter<Span> stackdriverReporter(ReporterMetrics reporterMetrics,
    GcpTraceProperties trace, @Qualifier(SENDER_BEAN_NAME) Sender sender) {
  return AsyncReporter.builder(sender)
      // historical constraint. Note: AsyncReporter supports memory bounds
      .queuedMaxSpans(1000)
      .messageTimeout(trace.getMessageTimeout(), TimeUnit.SECONDS)
      .metrics(reporterMetrics).build(StackdriverEncoder.V1);
}

代码示例来源:origin: jiangmin168168/jim-framework

protected AsyncReporter<Span> spanReporter() {
  return AsyncReporter
      .builder(getSender())
      .closeTimeout(500, TimeUnit.MILLISECONDS)
      .build(SpanBytesEncoder.JSON_V2);
}

代码示例来源:origin: io.zipkin.java/zipkin-server

/** Configuration for how to buffer spans into messages for Zipkin */
@Bean
Reporter<Span> reporter(
  Sender sender,
  @Value("${zipkin.self-tracing.message-timeout:1}") int messageTimeout,
  CollectorMetrics metrics) {
 return AsyncReporter.builder(sender)
   .messageTimeout(messageTimeout, TimeUnit.SECONDS)
   .metrics(new ReporterMetricsAdapter(metrics.forTransport("local")))
   .build();
}

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

protected ZipkinTracer(Sender sender, Config config, StatsReceiver stats) {
 this(AsyncReporter.builder(sender)
   .metrics(new ReporterMetricsAdapter(stats))
   .build(), config, stats);
}

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

protected ZipkinTracer(Sender sender, Config config, StatsReceiver stats) {
 this(AsyncReporter.builder(sender)
   .metrics(new ReporterMetricsAdapter(stats))
   .build(), config, stats);
}

代码示例来源:origin: org.springframework.cloud/spring-cloud-sleuth-zipkin

@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: org.springframework.cloud/spring-cloud-sleuth-zipkin

/**
 * 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: ZhuBaker/Tracing

/**
 * 构建
 * @param zipkinUrl
 * @return
 */
protected  AsyncReporter<Span> spanReporter(String zipkinUrl) {
  Sender sender = getSender(zipkinUrl);
  AsyncReporter asyncReporter = AsyncReporter.builder(sender)
      .closeTimeout(500, TimeUnit.MILLISECONDS)
      .build(SpanBytesEncoder.JSON_V2);
  return asyncReporter;
}

代码示例来源:origin: xjdr/xio

Reporter<Span> buildReporter(@NonNull String zipkinUrl) {
 OkHttpClient.Builder clientBuilder = OkHttpClientBuilderFactory.createZipkinClientBuilder();
 OkHttpSender sender =
   OkHttpSenderBuilderFactory.createSenderBuilder(clientBuilder)
     .encoding(Encoding.JSON)
     .endpoint(zipkinUrl)
     .compressionEnabled(false)
     .build();
 return AsyncReporter.builder(sender).build();
}

代码示例来源:origin: org.springframework.cloud/spring-cloud-sleuth-zipkin2

/**
 * Accepts a sender so you can plug-in any standard one. Returns a Reporter so you can also
 * replace with a standard one.
 */
@Bean
@ConditionalOnMissingBean
public Reporter<Span> reporter(
    SpanMetricReporter spanMetricReporter,
    ZipkinProperties zipkin,
    Sender sender
) {
  return AsyncReporter.builder(sender)
      .queuedMaxSpans(1000) // historical constraint. Note: AsyncReporter supports memory bounds
      .messageTimeout(zipkin.getMessageTimeout(), TimeUnit.SECONDS)
      .metrics(new ReporterMetricsAdapter(spanMetricReporter))
      .build(zipkin.getEncoder());
}

代码示例来源:origin: com.tencent.tars/tars-core

public void init() {
  isTrace = serverConfig.getSampleRate() > 0;
  if (isTrace) {
    try {
      createSender();
      reporter = AsyncReporter.builder(sender).build();
      Map<String, Tracer> traces = new HashMap<String, Tracer>();
      for (String servant : serverConfig.getServantAdapterConfMap().keySet()) {
        if (!servant.equals(OmConstants.AdminServant)) {
          Tracing tracing = Tracing.newBuilder().localServiceName(servant)
              .spanReporter(reporter).sampler(brave.sampler.Sampler.create(serverConfig.getSampleRate())).build();
          Tracer tracer = BraveTracer.create(tracing);
          traces.put(servant, tracer);
        }
      }
      TraceManager.getInstance().putTracers(traces);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}

代码示例来源: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: yangfuhai/jboot

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();
}

相关文章