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


Java Brave类代码示例

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


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

示例1: test_jedis_tracer

import com.github.kristofa.brave.Brave; //导入依赖的package包/类
@Test
public void test_jedis_tracer() throws Exception {
    Brave.Builder builder = new Brave.Builder("jedis-interceptor-test");
    builder.spanCollector(HttpSpanCollector.create("http://192.168.150.132:9411", new EmptySpanCollectorMetricsHandler()));
    builder.traceSampler(Sampler.ALWAYS_SAMPLE);
    Brave brave = builder.build();
    JaRedisInterceptor.setClientTracer(brave.clientTracer());

    JedisPoolConfig config = new JedisPoolConfig();
    JaRedisPool proxyPool = new JaRedisPool(config, "127.0.0.1", 6379);
    Jedis jedis = proxyPool.getResource();
    jedis.set("hello", "world");
    Assert.assertEquals(jedis.get("hello"), "world");
    jedis.hgetAll("hello-map");
    jedis.close();
    // sleep 3s in case spanCollector not flushed
    Thread.sleep(3000);
}
 
开发者ID:YanXs,项目名称:nighthawk,代码行数:19,代码来源:TestJedisProxyPool.java

示例2: main

import com.github.kristofa.brave.Brave; //导入依赖的package包/类
static public void main(String[] args) throws IOException, InterruptedException {
  Brave brave = Constant.brave("goodbye-service");
  ManagedChannel channel = ManagedChannelBuilder.forAddress("localhost", 8080)
      .usePlaintext(true)
      .intercept(new BraveGrpcClientInterceptor(brave))
      .build();
  GreetingServiceGrpc.GreetingServiceBlockingStub greetingStub = GreetingServiceGrpc.newBlockingStub(channel);

  Server goodbyeServer = ServerBuilder.forPort(9090)
      .addService(ServerInterceptors.intercept(new GoodbyeServiceImpl(greetingStub),
          new BraveGrpcServerInterceptor(brave),
          MonitoringServerInterceptor.create(Configuration.allMetrics())))
      .build();

  goodbyeServer.start();

  PrometheusServer prometheusServer = new PrometheusServer(CollectorRegistry.defaultRegistry, 8081);
  prometheusServer.start();

  System.out.println("Server started!");
  goodbyeServer.awaitTermination();
  prometheusServer.shutdown();
}
 
开发者ID:saturnism,项目名称:grpc-java-by-example,代码行数:24,代码来源:GoodbyeServer.java

示例3: applySampling

import com.github.kristofa.brave.Brave; //导入依赖的package包/类
private static Brave.Builder applySampling(final Brave.Builder builder, final JsonObject json) {
  Sampler sampler;
  float rate;
  switch (json.getString("type", "boundary")) {
    case "counting":
      rate = json.getFloat("rate", 0.01f);
      sampler = CountingSampler.create(rate);
      break;
    case "boundary":
    default:
      rate = json.getFloat("rate", 0.001f);
      sampler = BoundarySampler.create(rate);
      break;
  }
  logger.debug("Configuring sampler: {} at rate {}", sampler, rate);
  return builder.traceSampler(sampler);
}
 
开发者ID:emmanuelidi,项目名称:vertx-zipkin,代码行数:18,代码来源:BraveFactory.java

示例4: applySpanCollector

import com.github.kristofa.brave.Brave; //导入依赖的package包/类
private static Brave.Builder applySpanCollector(final Brave.Builder builder, final JsonObject json) {
  SpanCollector spanCollector;
  switch (json.getString("type")) {
    case "logging":
      spanCollector = new LoggingSpanCollector();
      break;
    case "scribe":
      spanCollector = ScribeSpanCollectorBuilder.build(json);
      break;
    case "kafka":
      spanCollector = KafkaSpanCollectorBuilder.build(json);
      break;
    case "empty":
    default:
      spanCollector = new EmptySpanCollector();
  }
  logger.debug("Configuring span collector: {}", spanCollector);
  return builder.spanCollector(spanCollector);
}
 
开发者ID:emmanuelidi,项目名称:vertx-zipkin,代码行数:20,代码来源:BraveFactory.java

示例5: getBrave

import com.github.kristofa.brave.Brave; //导入依赖的package包/类
private Brave getBrave(String serviceName) {
    Brave brave = null;
    if (serviceName != null) {
        brave = braves.get(serviceName);

        if (brave == null && useFallbackServiceNames) {
            LOG.debug("Creating Brave assigned to serviceName: {}", serviceName + " as fallback");
            Brave.Builder builder = new Brave.Builder(serviceName);
            builder = builder.traceSampler(Sampler.create(rate));
            if (spanCollector != null) {
                builder = builder.spanCollector(spanCollector);
            }
            brave = builder.build();
            braves.put(serviceName, brave);
        }
    }

    return brave;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:ZipkinTracer.java

示例6: run

import com.github.kristofa.brave.Brave; //导入依赖的package包/类
@Override
public void run(AppConfiguration configuration, Environment environment) throws Exception {
    configuration.getZipkinClient().setTimeout(Duration.seconds(50));
    configuration.getZipkinClient().setConnectionRequestTimeout(Duration.seconds(50));

    Brave brave = configuration.getZipkinFactory().build(environment).get();

    final Client client = new ZipkinClientBuilder(environment, brave)
            .build(configuration.getZipkinClient());

    new MySQLStatementInterceptorManagementBean(brave.clientTracer());

    /**
     * Database
     */
    createDatabase();
    DatabaseUtils.executeDatabaseScript("init.sql");

    UserDAO userDAO = new UserDAO();

    // Register resources
    environment.jersey().register(new HelloHandler());
    environment.jersey().register(new SyncHandler(client));
    environment.jersey().register(new AsyncHandler(client, brave));
    environment.jersey().register(new UsersHandler(userDAO, client, brave));
}
 
开发者ID:hawkular,项目名称:hawkular-apm,代码行数:27,代码来源:App.java

示例7: run

import com.github.kristofa.brave.Brave; //导入依赖的package包/类
@Override
public void run(C configuration, Environment environment) throws Exception {
  this.configuration = configuration;
  this.environment = environment;
  run(configuration, µsBundleInstance.µsEnvironment(this.environment));
  if (configuration instanceof ZipkinAware) {
    Brave brave = ((ZipkinAware)configuration).getZipkin().build(environment);
  }
  configureMapper(configuration, environment.getObjectMapper());
  if (configuration instanceof ValidatorAware) {
    environment.jersey().register(ValidationResource.class);
  }
  if (configuration instanceof SwaggerAware) {
    environment.jersey().register(SwaggerSerializers.class);
    environment.jersey().register(ApiListingResource.class);
    environment.jersey().register(AcceptHeaderApiListingResource.class);
  }
}
 
开发者ID:rvs-fluid-it,项目名称:microservice-bundle,代码行数:19,代码来源:µService.java

示例8: configure

import com.github.kristofa.brave.Brave; //导入依赖的package包/类
@Override
public void configure(Map<String, ?> configs, boolean isKey) {
    if (isKey) {
        throw new IllegalArgumentException("this must be a value serializer");
    }
    brave = (Brave) configs.get("tracing.component");
    if (brave == null) {
        throw new IllegalArgumentException("brave must not be null in tracingSerializer");
    }
}
 
开发者ID:YanXs,项目名称:nighthawk,代码行数:11,代码来源:AbstractTracingSerializer.java

示例9: test

import com.github.kristofa.brave.Brave; //导入依赖的package包/类
@Test
public void test() throws Exception {
    Properties props = new Properties();
    props.put("bootstrap.servers", "127.0.0.1:9092");//该地址是集群的子集,用来探测集群。
    props.put(ConsumerConfig.GROUP_ID_CONFIG, "test-consumer-group");
    props.put("acks", "all");// 记录完整提交,最慢的但是最大可能的持久化
    props.put("retries", 3);// 请求失败重试的次数
    props.put("batch.size", 16384);// batch的大小
    props.put("linger.ms", 1);// 默认情况即使缓冲区有剩余的空间,也会立即发送请求,设置一段时间用来等待从而将缓冲区填的更多,单位为毫秒,producer发送数据会延迟1ms,可以减少发送到kafka服务器的请求数据
    props.put("buffer.memory", 33554432);// 提供给生产者缓冲内存总量
    props.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
    props.put("value.deserializer.tracing.codec", Codec.JSON);
    props.put("value.deserializer", "org.apache.kafka.common.serialization.ByteArrayDeserializer");
    Consumer<String, byte[]> consumer = new KafkaConsumer<>(props);
    ListenableTracingConsumer<String, String> listenableTracingConsumer =
            new ListenableTracingConsumer<>(consumer, Pattern.compile("test"), new StringDeserializer());
    BraveFactoryBean factoryBean = new BraveFactoryBean();
    factoryBean.setServiceName("kafka-test");
    factoryBean.setTransport("http");
    factoryBean.setTransportAddress("127.0.0.1:9411");
    factoryBean.afterPropertiesSet();
    Brave brave = factoryBean.getObject();
    listenableTracingConsumer.addListener(new AbstractTracingListener<String, String>(brave) {
        @Override
        public void onPayload(Payload<String, String> payload) {
            try {
                System.out.println("key: " + payload.key());
                System.out.println("value: " + payload.value());
                Sleeper.JUST.sleepFor(2000, TimeUnit.MILLISECONDS);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    });
    listenableTracingConsumer.start();
    System.in.read();
}
 
开发者ID:YanXs,项目名称:nighthawk,代码行数:38,代码来源:ListenableTracingConsumerTest.java

示例10: test

import com.github.kristofa.brave.Brave; //导入依赖的package包/类
@Test
public void test() throws Exception {

    BraveFactoryBean factoryBean = new BraveFactoryBean();
    factoryBean.setServiceName("kafka-test");
    factoryBean.setTransport("http");
    factoryBean.setTransportAddress("127.0.0.1:9411");
    factoryBean.afterPropertiesSet();
    Brave brave = factoryBean.getObject();

    Properties props = new Properties();
    props.put("bootstrap.servers", "127.0.0.1:9092");//该地址是集群的子集,用来探测集群。
    props.put("acks", "all");// 记录完整提交,最慢的但是最大可能的持久化
    props.put("retries", 3);// 请求失败重试的次数
    props.put("batch.size", 16384);// batch的大小
    props.put("linger.ms", 1);// 默认情况即使缓冲区有剩余的空间,也会立即发送请求,设置一段时间用来等待从而将缓冲区填的更多,单位为毫秒,producer发送数据会延迟1ms,可以减少发送到kafka服务器的请求数据
    props.put("buffer.memory", 33554432);// 提供给生产者缓冲内存总量
    props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
    props.put("tracing.component", brave);
    props.put("value.serializer", "com.github.nightawk.mq.kafka.ByteArrayTracingSerializer");


    KafkaProducer<String, byte[]> producer = new KafkaProducer<>(props);
    for (int i = 0; i < 1000; i++) {
        producer.send(new ProducerRecord<>("test", "hello", ("kafka - " + i).getBytes()));
        Thread.sleep(10000);
    }
}
 
开发者ID:YanXs,项目名称:nighthawk,代码行数:29,代码来源:TracingProducerTest.java

示例11: braveServletFilter

import com.github.kristofa.brave.Brave; //导入依赖的package包/类
@Bean
public BraveServletFilter braveServletFilter(Brave brave) {
  BraveServletFilter filter =
      new BraveServletFilter(
          brave.serverRequestInterceptor(),
          brave.serverResponseInterceptor(),
          new DefaultSpanNameProvider());
  return filter;
}
 
开发者ID:junzixiehui,项目名称:godeye,代码行数:10,代码来源:ZipkinConfig.java

示例12: okHttpClient

import com.github.kristofa.brave.Brave; //导入依赖的package包/类
@Bean
public OkHttpClient okHttpClient(Brave brave) {
  OkHttpClient client =
      new OkHttpClient.Builder()
          .addInterceptor(
              new BraveOkHttpRequestResponseInterceptor(
                  brave.clientRequestInterceptor(),
                  brave.clientResponseInterceptor(),
                  new DefaultSpanNameProvider()))
          .build();
  return client;
}
 
开发者ID:junzixiehui,项目名称:godeye,代码行数:13,代码来源:ZipkinConfig.java

示例13: setup

import com.github.kristofa.brave.Brave; //导入依赖的package包/类
@Before
public void setup() {
	boot = new CrnkBoot();
	boot.setServiceDiscovery(new ReflectionsServiceDiscovery("io.crnk.test.mock.repository", new SampleJsonServiceLocator
			()));
	boot.boot();

	localTracer = Mockito.mock(LocalTracer.class);
	brave = Mockito.mock(Brave.class);
	Mockito.when(brave.localTracer()).thenReturn(localTracer);

	moduleContext = Mockito.mock(Module.ModuleContext.class);
	Mockito.when(moduleContext.getResourceRegistry()).thenReturn(boot.getResourceRegistry());

	QuerySpec querySpec = new QuerySpec(Task.class);
	queryAdapter = new QuerySpecAdapter(querySpec, boot.getResourceRegistry());

	ResourceInformation taskResourceInformation = boot.getResourceRegistry().getEntry(Task.class).getResourceInformation();
	requestSpec = Mockito.mock(RepositoryRequestSpec.class);
	Mockito.when(requestSpec.getMethod()).thenReturn(HttpMethod.GET);
	Mockito.when(requestSpec.getQueryAdapter()).thenReturn(queryAdapter);
	Mockito.when(requestSpec.getQuerySpec(taskResourceInformation))
			.thenReturn(querySpec);

	filter = new BraveRepositoryFilter(brave, moduleContext);
	filterContext = Mockito.mock(RepositoryFilterContext.class);
	Mockito.when(filterContext.getRequest()).thenReturn(requestSpec);

	filterChain = Mockito.mock(RepositoryRequestFilterChain.class);
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:31,代码来源:BraveResponseFilterTest.java

示例14: activate

import com.github.kristofa.brave.Brave; //导入依赖的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);
}
 
开发者ID:cschneider,项目名称:brave-osgi-example,代码行数:10,代码来源:BraveExporter.java

示例15: inlineBraveSetup

import com.github.kristofa.brave.Brave; //导入依赖的package包/类
@Test
public void inlineBraveSetup() {
    Reporter<Span> local = new Reporter<Span>() {

        @Override
        public void report(Span span) {
            spans.add(span);
        }
    };
    Brave brave = new Brave.Builder().reporter(local).build();
    brave.localTracer().startNewSpan("test", "testop");
    brave.localTracer().finishSpan();
    Assert.assertThat(1, equalTo(spans.size()));
}
 
开发者ID:openzipkin,项目名称:brave-karaf,代码行数:15,代码来源:BraveTest.java


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