当前位置: 首页>>代码示例>>Java>>正文


Java TracingKafkaConsumer类代码示例

本文整理汇总了Java中io.opentracing.contrib.kafka.TracingKafkaConsumer的典型用法代码示例。如果您正苦于以下问题:Java TracingKafkaConsumer类的具体用法?Java TracingKafkaConsumer怎么用?Java TracingKafkaConsumer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TracingKafkaConsumer类属于io.opentracing.contrib.kafka包,在下文中一共展示了TracingKafkaConsumer类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import io.opentracing.contrib.kafka.TracingKafkaConsumer; //导入依赖的package包/类
public void run(Configuration configuration, Environment environment) throws Exception {
  // INSTRUMENTATION
  // Metrics Instrumentation
  final CollectorRegistry collectorRegistry = new CollectorRegistry();
  collectorRegistry.register(new DropwizardExports(environment.metrics()));
  environment.admin()
      .addServlet("metrics", new MetricsServlet(collectorRegistry))
      .addMapping("/metrics");

  final PrometheusMetricsReporter reporter = PrometheusMetricsReporter.newMetricsReporter()
      .withCollectorRegistry(collectorRegistry)
      .withConstLabel("service", getName())
      .build();

  // Tracing Instrumentation
  final Tracer tracer = getTracer();
  final Tracer metricsTracer = io.opentracing.contrib.metrics.Metrics.decorate(tracer, reporter);
  GlobalTracer.register(metricsTracer);

  final HttpHost httpHost = new HttpHost("tweets-elasticsearch", 9200);
  final RestClientBuilder restClientBuilder =
      RestClient.builder(httpHost).setHttpClientConfigCallback(new TracingHttpClientConfigCallback(metricsTracer));
  final RestClient restClient = restClientBuilder.build();
  final ElasticsearchTweetRepository elasticsearchRepository = new ElasticsearchTweetRepository(restClient);

  final Properties consumerConfigs = new Properties();
  consumerConfigs.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "tweets-kafka:9092");
  consumerConfigs.put(ConsumerConfig.GROUP_ID_CONFIG, getName());
  consumerConfigs.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
  consumerConfigs.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, false);
  final KafkaConsumer<Long, String> kafkaConsumer = new KafkaConsumer<>(consumerConfigs, new LongDeserializer(), new StringDeserializer());
  final TracingKafkaConsumer<Long, String> tracingKafkaConsumer = new TracingKafkaConsumer<>(kafkaConsumer, metricsTracer);
  final Runnable kafkaTweetEventConsumer = new KafkaTweetEventConsumer(tracingKafkaConsumer, elasticsearchRepository);
  final ExecutorService executorService = environment.lifecycle().executorService("kafka-consumer").build();
  executorService.submit(kafkaTweetEventConsumer);
}
 
开发者ID:jeqo,项目名称:talk-observing-distributed-systems,代码行数:37,代码来源:IndexerServiceApplication.java

示例2: getConsumer

import io.opentracing.contrib.kafka.TracingKafkaConsumer; //导入依赖的package包/类
@Override
public Consumer<byte[], byte[]> getConsumer(Map<String, Object> config) {
  return new TracingKafkaConsumer<>(
      new KafkaConsumer<>(config, new ByteArrayDeserializer(), new ByteArrayDeserializer()),
      tracer);
}
 
开发者ID:opentracing-contrib,项目名称:java-kafka-client,代码行数:7,代码来源:TracingKafkaClientSupplier.java

示例3: getRestoreConsumer

import io.opentracing.contrib.kafka.TracingKafkaConsumer; //导入依赖的package包/类
@Override
public Consumer<byte[], byte[]> getRestoreConsumer(Map<String, Object> config) {
  return new TracingKafkaConsumer<>(
      new KafkaConsumer<>(config, new ByteArrayDeserializer(), new ByteArrayDeserializer()),
      tracer);
}
 
开发者ID:opentracing-contrib,项目名称:java-kafka-client,代码行数:7,代码来源:TracingKafkaClientSupplier.java

示例4: createConsumer

import io.opentracing.contrib.kafka.TracingKafkaConsumer; //导入依赖的package包/类
@Override
public Consumer<K, V> createConsumer() {
  return new TracingKafkaConsumer<>(consumerFactory.createConsumer(), tracer);
}
 
开发者ID:opentracing-contrib,项目名称:java-kafka-client,代码行数:5,代码来源:TracingConsumerFactory.java


注:本文中的io.opentracing.contrib.kafka.TracingKafkaConsumer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。