本文整理汇总了Java中org.springframework.cloud.sleuth.SpanReporter类的典型用法代码示例。如果您正苦于以下问题:Java SpanReporter类的具体用法?Java SpanReporter怎么用?Java SpanReporter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SpanReporter类属于org.springframework.cloud.sleuth包,在下文中一共展示了SpanReporter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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");
}
开发者ID:spring-cloud,项目名称:spring-cloud-sleuth,代码行数:20,代码来源:ZipkinAutoConfigurationTests.java
示例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");
}
开发者ID:spring-cloud,项目名称:spring-cloud-sleuth,代码行数:21,代码来源:ZipkinAutoConfigurationTests.java
示例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();
}
开发者ID:spring-cloud,项目名称:spring-cloud-sleuth,代码行数:18,代码来源:ZipkinAutoConfigurationTests.java
示例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();
}
开发者ID:spring-cloud,项目名称:spring-cloud-sleuth,代码行数:18,代码来源:ZipkinAutoConfigurationTests.java
示例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();
}
开发者ID:spring-cloud,项目名称:spring-cloud-sleuth,代码行数:20,代码来源:ZipkinAutoConfigurationTests.java
示例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();
}
开发者ID:spring-cloud,项目名称:spring-cloud-sleuth,代码行数:18,代码来源:ZipkinAutoConfigurationTests.java
示例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();
}
开发者ID:spring-cloud,项目名称:spring-cloud-sleuth,代码行数:22,代码来源:TraceFilterTests.java
示例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();
}
开发者ID:spring-cloud,项目名称:spring-cloud-sleuth,代码行数:17,代码来源:TraceFilterTests.java
示例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();
}
开发者ID:spring-cloud,项目名称:spring-cloud-sleuth,代码行数:17,代码来源:TraceFilterTests.java
示例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();
}
开发者ID:spring-cloud,项目名称:spring-cloud-sleuth,代码行数:19,代码来源:TraceFilterTests.java
示例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);
}
开发者ID:spring-cloud,项目名称:spring-cloud-gcp,代码行数:11,代码来源:StackdriverTraceAutoConfiguration.java
示例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);
}
开发者ID:spring-cloud,项目名称:spring-cloud-gcp,代码行数:9,代码来源:StackdriverTraceAutoConfiguration.java
示例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;
}
开发者ID:reshmik,项目名称:Zipkin,代码行数:11,代码来源:TraceWebAutoConfiguration.java
示例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);
}
开发者ID:reshmik,项目名称:Zipkin,代码行数:10,代码来源:TraceWebAutoConfiguration.java
示例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);
}
开发者ID:reshmik,项目名称:Zipkin,代码行数:8,代码来源:TraceFilter.java
示例16: sleuthTracer
import org.springframework.cloud.sleuth.SpanReporter; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean(Tracer.class)
public DefaultTracer sleuthTracer(Sampler sampler, Random random,
SpanNamer spanNamer, SpanLogger spanLogger,
SpanReporter spanReporter) {
return new DefaultTracer(sampler, random, spanNamer, spanLogger,
spanReporter);
}
开发者ID:reshmik,项目名称:Zipkin,代码行数:9,代码来源:TraceAutoConfiguration.java
示例17: DefaultTracer
import org.springframework.cloud.sleuth.SpanReporter; //导入依赖的package包/类
public DefaultTracer(Sampler defaultSampler, Random random, SpanNamer spanNamer,
SpanLogger spanLogger, SpanReporter spanReporter) {
this.defaultSampler = defaultSampler;
this.random = random;
this.spanNamer = spanNamer;
this.spanLogger = spanLogger;
this.spanReporter = spanReporter;
}
开发者ID:reshmik,项目名称:Zipkin,代码行数:9,代码来源:DefaultTracer.java
示例18: 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, this.properties.isTraceId128(), traceKeys);
}
开发者ID:spring-cloud,项目名称:spring-cloud-sleuth,代码行数:9,代码来源:TraceAutoConfiguration.java
示例19: DefaultTracer
import org.springframework.cloud.sleuth.SpanReporter; //导入依赖的package包/类
public DefaultTracer(Sampler defaultSampler, Random random, SpanNamer spanNamer,
SpanLogger spanLogger, SpanReporter spanReporter, boolean traceId128,
TraceKeys traceKeys) {
this.defaultSampler = defaultSampler;
this.random = random;
this.spanNamer = spanNamer;
this.spanLogger = spanLogger;
this.spanReporter = spanReporter;
this.traceId128 = traceId128;
this.traceKeys = traceKeys != null ? traceKeys : new TraceKeys();
}
开发者ID:spring-cloud,项目名称:spring-cloud-sleuth,代码行数:12,代码来源:DefaultTracer.java
示例20: continuesSpanFromHeaders
import org.springframework.cloud.sleuth.SpanReporter; //导入依赖的package包/类
@Test
public void continuesSpanFromHeaders() throws Exception {
this.request = builder().header(Span.SPAN_ID_NAME, PARENT_ID)
.header(Span.TRACE_ID_NAME, 20L).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);
verifyParentSpanHttpTags();
then(TestSpanContextHolder.getCurrentSpan()).isNull();
}
开发者ID:spring-cloud,项目名称:spring-cloud-sleuth,代码行数:15,代码来源:TraceFilterTests.java
注:本文中的org.springframework.cloud.sleuth.SpanReporter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论