本文整理汇总了Java中brave.sampler.Sampler类的典型用法代码示例。如果您正苦于以下问题:Java Sampler类的具体用法?Java Sampler怎么用?Java Sampler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Sampler类属于brave.sampler包,在下文中一共展示了Sampler类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createZipkin
import brave.sampler.Sampler; //导入依赖的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());
}
开发者ID:jaegertracing,项目名称:spark-dependencies,代码行数:17,代码来源:TracersGenerator.java
示例2: httpTracer
import brave.sampler.Sampler; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public Tracing httpTracer(Config config, Map<String, String> properties, Reporter reporter) {
Sampler sampler = Sampler.ALWAYS_SAMPLE;
try {
ServiceReference<Sampler>[] samplers =
(ServiceReference<Sampler>[]) context.getAllServiceReferences(
Sampler.class.getName(), config.samplerFilter());
if (samplers != null && samplers.length > 0) {
sampler = context.getService(samplers[0]);
}
} catch (InvalidSyntaxException e) {
}
Tracing.Builder tracingBuilder = Tracing.newBuilder();
tracingBuilder.localServiceName(config.localServiceName());
tracingBuilder.sampler(sampler);
tracingBuilder.reporter(reporter);
tracingBuilder.currentTraceContext(MDCCurrentTraceContext.create());
return tracingBuilder.build();
}
开发者ID:openzipkin,项目名称:brave-karaf,代码行数:26,代码来源:OkHttp3ReporterExporter.java
示例3: tracing
import brave.sampler.Sampler; //导入依赖的package包/类
@Provides
@Singleton
static Tracing tracing(Lazy<StackdriverReporter> reporter, MonitoringConfig config) {
Tracing.Builder builder =
Tracing.newBuilder()
.localServiceName(config.getServerName())
.traceId128Bit(true)
.sampler(Sampler.ALWAYS_SAMPLE);
if (config.isReportTraces()) {
builder.spanReporter(reporter.get());
}
return builder.build();
}
开发者ID:curioswitch,项目名称:curiostack,代码行数:14,代码来源:MonitoringModule.java
示例4: setup
import brave.sampler.Sampler; //导入依赖的package包/类
@Before public void setup() throws IOException {
tracing = tracingBuilder(Sampler.ALWAYS_SAMPLE).build();
cluster = Cluster.builder()
.addContactPointsWithPorts(Collections.singleton(cassandra.contactPoint()))
.build();
session = newSession();
CustomPayloadCaptor.ref.set(null);
}
开发者ID:openzipkin,项目名称:brave-cassandra,代码行数:9,代码来源:ITTracingSession.java
示例5: propagatesSampledFalse
import brave.sampler.Sampler; //导入依赖的package包/类
@Test public void propagatesSampledFalse() throws Exception {
tracing = tracingBuilder(Sampler.NEVER_SAMPLE).build();
session.close();
session = newSession();
invokeBoundStatement();
assertThat(CustomPayloadCaptor.ref.get().get("X-B3-Sampled"))
.extracting(ByteBuffer::get)
.containsExactly('0');
}
开发者ID:openzipkin,项目名称:brave-cassandra,代码行数:11,代码来源:ITTracingSession.java
示例6: getSampler
import brave.sampler.Sampler; //导入依赖的package包/类
@JsonIgnore
public Sampler getSampler() {
if (sampler == null) {
return Sampler.create(sampleRate);
}
return sampler;
}
开发者ID:smoketurner,项目名称:dropwizard-zipkin,代码行数:8,代码来源:AbstractZipkinFactory.java
示例7: shouldSubmitSpanWhenSampled
import brave.sampler.Sampler; //导入依赖的package包/类
@Test(timeout = 20000)
public void shouldSubmitSpanWhenSampled() throws Exception {
SpanCollectingReporter reporter = new SpanCollectingReporter();
Tracing tracing = Tracing.newBuilder()
.localServiceName(TEST_SERVICE)
.spanReporter(reporter)
.sampler(Sampler.create(1.0f))
.build();
testRemoteInvocation(tracing, null);
// check span name
Span span = reporter.spans().take();
assertThat(span.name()).isEqualTo(TEST_SPAN);
// check kind
assertThat(span.kind() == Kind.CLIENT);
// only one span should be submitted
assertThat(reporter.spans().poll(1, TimeUnit.SECONDS)).isNull();
// check # of annotations (zipkin2 format does not use them by default)
assertThat(span.annotations()).isEmpty();
// check tags
assertThat(span.tags()).containsAllEntriesOf(ImmutableMap.of(
"http.host", "localhost",
"http.method", "POST",
"http.path", "/hello/armeria",
"http.status_code", "200",
"http.url", "none+h2c://localhost/hello/armeria"));
// check service name
assertThat(span.localServiceName()).isEqualTo(TEST_SERVICE);
// check remote service name
assertThat(span.remoteServiceName()).isEqualTo("localhost");
}
开发者ID:line,项目名称:armeria,代码行数:39,代码来源:HttpTracingClientTest.java
示例8: shouldSubmitSpanWithCustomRemoteName
import brave.sampler.Sampler; //导入依赖的package包/类
@Test(timeout = 20000)
public void shouldSubmitSpanWithCustomRemoteName() throws Exception {
SpanCollectingReporter reporter = new SpanCollectingReporter();
Tracing tracing = Tracing.newBuilder()
.localServiceName(TEST_SERVICE)
.spanReporter(reporter)
.sampler(Sampler.create(1.0f))
.build();
testRemoteInvocation(tracing, "foo");
// check span name
Span span = reporter.spans().take();
// check tags
assertThat(span.tags()).containsAllEntriesOf(ImmutableMap.of(
"http.host", "localhost",
"http.method", "POST",
"http.path", "/hello/armeria",
"http.status_code", "200",
"http.url", "none+h2c://localhost/hello/armeria"));
// check service name
assertThat(span.localServiceName()).isEqualTo(TEST_SERVICE);
// check remote service name
assertThat(span.remoteServiceName()).isEqualTo("foo");
}
开发者ID:line,项目名称:armeria,代码行数:29,代码来源:HttpTracingClientTest.java
示例9: shouldNotSubmitSpanWhenNotSampled
import brave.sampler.Sampler; //导入依赖的package包/类
@Test
public void shouldNotSubmitSpanWhenNotSampled() throws Exception {
SpanCollectingReporter reporter = new SpanCollectingReporter();
Tracing tracing = Tracing.newBuilder()
.localServiceName(TEST_SERVICE)
.spanReporter(reporter)
.sampler(Sampler.create(0.0f))
.build();
testRemoteInvocation(tracing, null);
assertThat(reporter.spans().poll(1, TimeUnit.SECONDS)).isNull();
}
开发者ID:line,项目名称:armeria,代码行数:13,代码来源:HttpTracingClientTest.java
示例10: newTracing
import brave.sampler.Sampler; //导入依赖的package包/类
private static Tracing newTracing(String name) {
return Tracing.newBuilder()
.currentTraceContext(CurrentTraceContext.Default.create())
.localServiceName(name)
.spanReporter(spanReporter)
.sampler(Sampler.ALWAYS_SAMPLE)
.build();
}
开发者ID:line,项目名称:armeria,代码行数:9,代码来源:HttpTracingIntegrationTest.java
示例11: buildTracing
import brave.sampler.Sampler; //导入依赖的package包/类
private Tracing buildTracing(ApplicationConfig config) {
if (config.getZipkinUrl().isEmpty() || !(config.getSamplingRate() > 0f)) {
return null;
}
return Tracing.newBuilder()
.localServiceName(config.getName())
// puts trace IDs into logs
.currentTraceContext(MDCCurrentTraceContext.create())
.reporter(buildReporter(config))
.sampler(Sampler.create(config.getSamplingRate()))
.build();
}
开发者ID:xjdr,项目名称:xio,代码行数:13,代码来源:XioTracing.java
示例12: tracingBuilder
import brave.sampler.Sampler; //导入依赖的package包/类
Tracing.Builder tracingBuilder(Sampler sampler) {
return Tracing.newBuilder()
.reporter(
s -> {
// make sure the context was cleared prior to finish.. no leaks!
TraceContext current = httpTracing.tracing().currentTraceContext().get();
if (current != null) {
Assert.assertNotEquals(current.spanId(), s.id);
}
spans.add(s);
})
.currentTraceContext(currentTraceContext)
.sampler(sampler);
}
开发者ID:xjdr,项目名称:xio,代码行数:15,代码来源:HttpServerTracingHandlerTest.java
示例13: tracingBuilder
import brave.sampler.Sampler; //导入依赖的package包/类
Tracing.Builder tracingBuilder(Sampler sampler) {
return brave.Tracing.newBuilder()
.currentTraceContext(new StrictCurrentTraceContext())
.spanReporter(spans::add)
.sampler(sampler);
}
开发者ID:openzipkin,项目名称:brave-cassandra,代码行数:7,代码来源:ITTracingSession.java
示例14: setSampler
import brave.sampler.Sampler; //导入依赖的package包/类
@JsonIgnore
public void setSampler(@Nullable Sampler sampler) {
this.sampler = sampler;
}
开发者ID:smoketurner,项目名称:dropwizard-zipkin,代码行数:5,代码来源:AbstractZipkinFactory.java
示例15: harnessSetup
import brave.sampler.Sampler; //导入依赖的package包/类
void harnessSetup(Execution execution) {
currentTraceContext = new RatpackCurrentTraceContext(() -> execution);
httpTracing = HttpTracing.create(tracingBuilder(Sampler.ALWAYS_SAMPLE).build());
client = newClient(server.getPort());
}
开发者ID:hyleung,项目名称:ratpack-zipkin,代码行数:6,代码来源:ITTracingFeature_Client.java
示例16: testServiceInvocation
import brave.sampler.Sampler; //导入依赖的package包/类
private static SpanCollectingReporter testServiceInvocation(float samplingRate) throws Exception {
SpanCollectingReporter reporter = new SpanCollectingReporter();
Tracing tracing = Tracing.newBuilder()
.localServiceName(TEST_SERVICE)
.spanReporter(reporter)
.sampler(Sampler.create(samplingRate))
.build();
@SuppressWarnings("unchecked")
Service<HttpRequest, HttpResponse> delegate = mock(Service.class);
final HttpTracingService stub = new HttpTracingService(delegate, tracing);
final ServiceRequestContext ctx = mock(ServiceRequestContext.class);
final HttpRequest req = HttpRequest.of(HttpMethod.POST, "/hello/trustin");
final RpcRequest rpcReq = RpcRequest.of(HelloService.Iface.class, "hello", "trustin");
final HttpResponse res = HttpResponse.of(HttpStatus.OK);
final RpcResponse rpcRes = RpcResponse.of("Hello, trustin!");
final DefaultRequestLog log = new DefaultRequestLog(ctx);
log.startRequest(mock(Channel.class), H2C, "localhost");
log.requestContent(rpcReq, req);
log.endRequest();
// HttpTracingService prefers RpcRequest.method() to ctx.method(), so "POST" should be ignored.
when(ctx.method()).thenReturn(HttpMethod.POST);
when(ctx.log()).thenReturn(log);
when(ctx.logBuilder()).thenReturn(log);
when(ctx.path()).thenReturn("/hello/trustin");
ctx.onEnter(isA(Consumer.class));
ctx.onExit(isA(Consumer.class));
when(delegate.serve(ctx, req)).thenReturn(res);
// do invoke
stub.serve(ctx, req);
verify(delegate, times(1)).serve(eq(ctx), eq(req));
log.responseHeaders(HttpHeaders.of(HttpStatus.OK));
log.responseContent(rpcRes, res);
log.endResponse();
return reporter;
}
开发者ID:line,项目名称:armeria,代码行数:44,代码来源:HttpTracingServiceTest.java
示例17: setup
import brave.sampler.Sampler; //导入依赖的package包/类
@Before
public void setup() throws Exception {
httpTracing = HttpTracing.create(tracingBuilder(Sampler.ALWAYS_SAMPLE).build());
httpTracingState = new HttpServerTracingState(httpTracing, false);
}
开发者ID:xjdr,项目名称:xio,代码行数:6,代码来源:HttpServerTracingHandlerTest.java
注:本文中的brave.sampler.Sampler类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论