本文整理汇总了Java中org.springframework.cloud.sleuth.SpanReporter类的典型用法代码示例。如果您正苦于以下问题:Java SpanReporter类的具体用法?Java SpanReporter怎么用?Java SpanReporter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SpanReporter类属于org.springframework.cloud.sleuth包,在下文中一共展示了SpanReporter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: defaultsToV2Endpoint
import org.springframework.cloud.sleuth.SpanReporter; //导入依赖的package包/类
@Test
public void defaultsToV2Endpoint() throws Exception {
context = new AnnotationConfigApplicationContext();
addEnvironment(context, "spring.zipkin.base-url:" + server.url("/"));
context.register(
PropertyPlaceholderAutoConfiguration.class,
TraceMetricsAutoConfiguration.class,
ZipkinAutoConfiguration.class);
context.refresh();
SpanReporter spanReporter = context.getBean(SpanReporter.class);
spanReporter.report(span);
Awaitility.await().untilAsserted(() -> then(server.getRequestCount()).isGreaterThan(0));
RecordedRequest request = server.takeRequest();
then(request.getPath()).isEqualTo("/api/v2/spans");
then(request.getBody().readUtf8()).contains("localEndpoint");
}
示例2: encoderDirectsEndpoint
import org.springframework.cloud.sleuth.SpanReporter; //导入依赖的package包/类
@Test
public void encoderDirectsEndpoint() throws Exception {
context = new AnnotationConfigApplicationContext();
addEnvironment(
context, "spring.zipkin.base-url:" + server.url("/"), "spring.zipkin.encoder:JSON_V1");
context.register(
PropertyPlaceholderAutoConfiguration.class,
TraceMetricsAutoConfiguration.class,
ZipkinAutoConfiguration.class);
context.refresh();
SpanReporter spanReporter = context.getBean(SpanReporter.class);
spanReporter.report(span);
Awaitility.await().untilAsserted(() -> then(server.getRequestCount()).isGreaterThan(0));
RecordedRequest request = server.takeRequest();
then(request.getPath()).isEqualTo("/api/v1/spans");
then(request.getBody().readUtf8()).contains("binaryAnnotations");
}
示例3: overrideRabbitMQQueue
import org.springframework.cloud.sleuth.SpanReporter; //导入依赖的package包/类
@Test
public void overrideRabbitMQQueue() throws Exception {
context = new AnnotationConfigApplicationContext();
addEnvironment(context, "spring.zipkin.rabbitmq.queue:zipkin2");
context.register(
PropertyPlaceholderAutoConfiguration.class,
TraceMetricsAutoConfiguration.class,
RabbitAutoConfiguration.class,
ZipkinAutoConfiguration.class);
context.refresh();
SpanReporter spanReporter = context.getBean(SpanReporter.class);
assertThat(spanReporter).extracting("reporter.sender.queue")
.contains("zipkin2");
context.close();
}
示例4: overrideKafkaTopic
import org.springframework.cloud.sleuth.SpanReporter; //导入依赖的package包/类
@Test
public void overrideKafkaTopic() throws Exception {
context = new AnnotationConfigApplicationContext();
addEnvironment(context, "spring.zipkin.kafka.topic:zipkin2");
context.register(
PropertyPlaceholderAutoConfiguration.class,
TraceMetricsAutoConfiguration.class,
KafkaAutoConfiguration.class,
ZipkinAutoConfiguration.class);
context.refresh();
SpanReporter spanReporter = context.getBean(SpanReporter.class);
assertThat(spanReporter).extracting("reporter.sender.topic")
.contains("zipkin2");
context.close();
}
示例5: canOverrideBySender
import org.springframework.cloud.sleuth.SpanReporter; //导入依赖的package包/类
@Test
public void canOverrideBySender() throws Exception {
context = new AnnotationConfigApplicationContext();
addEnvironment(context, "spring.zipkin.sender.type:web");
context.register(
PropertyPlaceholderAutoConfiguration.class,
TraceMetricsAutoConfiguration.class,
RabbitAutoConfiguration.class,
KafkaAutoConfiguration.class,
ZipkinAutoConfiguration.class);
context.refresh();
SpanReporter spanReporter = context.getBean(SpanReporter.class);
assertThat(spanReporter).extracting("reporter.sender").allSatisfy(
s -> assertThat(s.getClass().getSimpleName()).isEqualTo("RestTemplateSender")
);
context.close();
}
示例6: rabbitWinsWhenKafkaPresent
import org.springframework.cloud.sleuth.SpanReporter; //导入依赖的package包/类
@Test
public void rabbitWinsWhenKafkaPresent() throws Exception {
context = new AnnotationConfigApplicationContext();
context.register(
PropertyPlaceholderAutoConfiguration.class,
TraceMetricsAutoConfiguration.class,
RabbitAutoConfiguration.class,
KafkaAutoConfiguration.class,
ZipkinAutoConfiguration.class);
context.refresh();
SpanReporter spanReporter = context.getBean(SpanReporter.class);
assertThat(spanReporter).extracting("reporter.sender")
.allSatisfy(s -> assertThat(s).isInstanceOf(RabbitMQSender.class));
context.close();
}
示例7: startsNewTraceWithParentIdInHeaders
import org.springframework.cloud.sleuth.SpanReporter; //导入依赖的package包/类
@Test
public void startsNewTraceWithParentIdInHeaders() throws Exception {
this.request = builder()
.header(Span.SPAN_ID_NAME, Span.idToHex(PARENT_ID))
.header(Span.TRACE_ID_NAME, Span.idToHex(2L))
.header(Span.PARENT_ID_NAME, Span.idToHex(3L))
.buildRequest(new MockServletContext());BeanFactory beanFactory = beanFactory();
BDDMockito.given(beanFactory.getBean(SpanReporter.class)).willReturn(this.spanReporter);
TraceFilter filter = new TraceFilter(beanFactory);
filter.doFilter(this.request, this.response, this.filterChain);
assertThat(this.span.getSpanId()).isEqualTo(PARENT_ID);
assertThat(this.span)
.hasATag("http.url", "http://localhost/?foo=bar")
.hasATag("http.host", "localhost")
.hasATag("http.path", "/")
.hasATag("http.method", "GET");
then(TestSpanContextHolder.getCurrentSpan()).isNull();
then(ExceptionUtils.getLastException()).isNull();
}
示例8: addsAdditionalHeaders
import org.springframework.cloud.sleuth.SpanReporter; //导入依赖的package包/类
@Test
public void addsAdditionalHeaders() throws Exception {
this.request = builder().header(Span.SPAN_ID_NAME, PARENT_ID)
.header(Span.TRACE_ID_NAME, 20L).buildRequest(new MockServletContext());
this.traceKeys.getHttp().getHeaders().add("x-foo");
BeanFactory beanFactory = beanFactory();
BDDMockito.given(beanFactory.getBean(SpanReporter.class)).willReturn(this.spanReporter);
TraceFilter filter = new TraceFilter(beanFactory);
this.request.addHeader("X-Foo", "bar");
filter.doFilter(this.request, this.response, this.filterChain);
assertThat(this.span.tags()).contains(entry("http.x-foo", "bar"));
assertThat(this.span.tags()).contains(entry("http.x-foo", "bar"));
then(TestSpanContextHolder.getCurrentSpan()).isNull();
}
示例9: additionalMultiValuedHeader
import org.springframework.cloud.sleuth.SpanReporter; //导入依赖的package包/类
@Test
public void additionalMultiValuedHeader() throws Exception {
this.request = builder().header(Span.SPAN_ID_NAME, PARENT_ID)
.header(Span.TRACE_ID_NAME, 20L).buildRequest(new MockServletContext());
this.traceKeys.getHttp().getHeaders().add("x-foo");BeanFactory beanFactory = beanFactory();
BDDMockito.given(beanFactory.getBean(SpanReporter.class)).willReturn(this.spanReporter);
TraceFilter filter = new TraceFilter(beanFactory);
this.request.addHeader("X-Foo", "bar");
this.request.addHeader("X-Foo", "spam");
filter.doFilter(this.request, this.response, this.filterChain);
assertThat(this.span.tags()).contains(entry("http.x-foo", "'bar','spam'"));
then(TestSpanContextHolder.getCurrentSpan()).isNull();
}
示例10: samplesWhenDebugFlagIsSetTo1AndOnlySpanIdIsSet
import org.springframework.cloud.sleuth.SpanReporter; //导入依赖的package包/类
@Test
public void samplesWhenDebugFlagIsSetTo1AndOnlySpanIdIsSet() throws Exception {
this.request = builder()
.header(Span.SPAN_FLAGS, 1)
.header(Span.SPAN_ID_NAME, 10L)
.buildRequest(new MockServletContext());
this.sampler = new NeverSampler();
BeanFactory beanFactory = beanFactory();
BDDMockito.given(beanFactory.getBean(SpanReporter.class)).willReturn(this.spanReporter);
TraceFilter filter = new TraceFilter(beanFactory);
filter.doFilter(this.request, this.response, this.filterChain);
then(new ListOfSpans(this.spanReporter.getSpans()))
.allSpansAreExportable().hasSize(1).hasASpanWithSpanId(Span.hexToId("10"));
then(TestSpanContextHolder.getCurrentSpan()).isNull();
then(ExceptionUtils.getLastException()).isNull();
}
示例11: traceSpanReporter
import org.springframework.cloud.sleuth.SpanReporter; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean
public SpanReporter traceSpanReporter(Environment environment,
LabelExtractor labelExtractor,
List<SpanAdjuster> spanAdjusters, TraceConsumer traceConsumer) {
String instanceId = IdUtils.getDefaultInstanceId(environment);
return new StackdriverTraceSpanListener(instanceId,
this.finalProjectIdProvider.getProjectId(), labelExtractor, spanAdjusters,
traceConsumer);
}
示例12: sleuthTracer
import org.springframework.cloud.sleuth.SpanReporter; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean(Tracer.class)
public Tracer sleuthTracer(Sampler sampler, Random random,
SpanNamer spanNamer, SpanLogger spanLogger,
SpanReporter spanReporter, TraceKeys traceKeys) {
return new DefaultTracer(sampler, random, spanNamer, spanLogger,
spanReporter, true, traceKeys);
}
示例13: traceWebFilter
import org.springframework.cloud.sleuth.SpanReporter; //导入依赖的package包/类
@Bean
public FilterRegistrationBean traceWebFilter(Tracer tracer, TraceKeys traceKeys,
SkipPatternProvider skipPatternProvider, SpanReporter spanReporter,
SpanExtractor<HttpServletRequest> spanExtractor,
SpanInjector<HttpServletResponse> spanInjector,
HttpTraceKeysInjector httpTraceKeysInjector, TraceFilter traceFilter) {
FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(traceFilter);
filterRegistrationBean.setDispatcherTypes(ASYNC, ERROR, FORWARD, INCLUDE, REQUEST);
return filterRegistrationBean;
}
示例14: traceFilter
import org.springframework.cloud.sleuth.SpanReporter; //导入依赖的package包/类
@Bean
public TraceFilter traceFilter(Tracer tracer, TraceKeys traceKeys,
SkipPatternProvider skipPatternProvider, SpanReporter spanReporter,
SpanExtractor<HttpServletRequest> spanExtractor,
SpanInjector<HttpServletResponse> spanInjector,
HttpTraceKeysInjector httpTraceKeysInjector) {
return new TraceFilter(tracer, traceKeys, skipPatternProvider.skipPattern(),
spanReporter, spanExtractor, spanInjector, httpTraceKeysInjector);
}
示例15: TraceFilter
import org.springframework.cloud.sleuth.SpanReporter; //导入依赖的package包/类
public TraceFilter(Tracer tracer, TraceKeys traceKeys, SpanReporter spanReporter,
SpanExtractor<HttpServletRequest> spanExtractor,
SpanInjector<HttpServletResponse> spanInjector,
HttpTraceKeysInjector httpTraceKeysInjector) {
this(tracer, traceKeys, Pattern.compile(DEFAULT_SKIP_PATTERN), spanReporter,
spanExtractor, spanInjector, httpTraceKeysInjector);
}