本文整理汇总了Java中com.github.kristofa.brave.Brave.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java Brave.Builder方法的具体用法?Java Brave.Builder怎么用?Java Brave.Builder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.kristofa.brave.Brave
的用法示例。
在下文中一共展示了Brave.Builder方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例2: 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);
}
示例3: 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);
}
示例4: 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;
}
示例5: create
import com.github.kristofa.brave.Brave; //导入方法依赖的package包/类
public static Brave create(final JsonObject json) {
// TODO: not really doing any error checking on the input json.
Brave.Builder builder = new Brave.Builder(json.getString("serviceName"));
builder = applySampling(builder, json.getJsonObject("sampler", new JsonObject()));
builder = applySpanCollector(builder, json.getJsonObject("collector", new JsonObject()));
return builder.build();
}
示例6: getBraveInstance
import com.github.kristofa.brave.Brave; //导入方法依赖的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();
}
示例7: create
import com.github.kristofa.brave.Brave; //导入方法依赖的package包/类
public Brave create() {
final Brave.Builder builder = new Brave.Builder();
final Brave brave = builder
.reporter(new LoggingReporter())
.traceSampler(Sampler.create(1.0f)) // retain 100% of traces
.build();
return brave;
}
示例8: createBraveForService
import com.github.kristofa.brave.Brave; //导入方法依赖的package包/类
private void createBraveForService(String pattern, String serviceName) {
Brave brave = braves.get(pattern);
if (brave == null && !braves.containsKey(serviceName)) {
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);
}
}
示例9: FeginZipkinTracingClient
import com.github.kristofa.brave.Brave; //导入方法依赖的package包/类
/**
* Constructor of FeginZipkinTracingClient.
*
* @param client
* @param instanceName
* @param zipkinUrl URL of the receiver of DAS server.
*/
public FeginZipkinTracingClient(Client client, String instanceName, String zipkinUrl) {
this.clientDelegate = client;
Brave.Builder builder = new Brave.Builder(instanceName);
builder.spanCollector(HttpSpanCollector.create(zipkinUrl, new EmptySpanCollectorMetricsHandler()));
Brave brave = builder.build();
requestInterceptor = brave.clientRequestInterceptor();
responseInterceptor = brave.clientResponseInterceptor();
}
示例10: MSF4JZipkinTracingInterceptor
import com.github.kristofa.brave.Brave; //导入方法依赖的package包/类
/**
* Constructor of the MSF4JTracingInterceptor.
*
* @param microServiceName Name of the Microservice
* @param zipkinUrl Base URL of the Zipkin server
*/
public MSF4JZipkinTracingInterceptor(String microServiceName, String zipkinUrl) {
Brave.Builder builder = new Brave.Builder(microServiceName);
builder.spanCollector(HttpSpanCollector.create(zipkinUrl, new EmptySpanCollectorMetricsHandler()));
Brave brave = builder.build();
reqInterceptor = brave.serverRequestInterceptor();
respInterceptor = brave.serverResponseInterceptor();
}