本文整理汇总了Java中io.opentracing.util.ThreadLocalActiveSpanSource类的典型用法代码示例。如果您正苦于以下问题:Java ThreadLocalActiveSpanSource类的具体用法?Java ThreadLocalActiveSpanSource怎么用?Java ThreadLocalActiveSpanSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ThreadLocalActiveSpanSource类属于io.opentracing.util包,在下文中一共展示了ThreadLocalActiveSpanSource类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testWithStartTimestamp
import io.opentracing.util.ThreadLocalActiveSpanSource; //导入依赖的package包/类
@Test
public void testWithStartTimestamp() throws InterruptedException {
MetricsReporter reporter = Mockito.mock(MetricsReporter.class);
MockTracer tracer = new MockTracer(new ThreadLocalActiveSpanSource());
Tracer metricsTracer = Metrics.decorate(tracer, reporter);
long start = System.currentTimeMillis() * 687;
Thread.sleep(100);
ActiveSpan parent = metricsTracer.buildSpan("parent")
.withStartTimestamp(start)
.startActive();
parent.deactivate();
List<MockSpan> spans = tracer.finishedSpans();
assertEquals(1, spans.size());
MockSpan span = spans.get(0);
long started = span.startMicros();
assertEquals(start, started);
}
开发者ID:opentracing-contrib,项目名称:java-metrics,代码行数:21,代码来源:MetricsTest.java
示例2: testWithTags
import io.opentracing.util.ThreadLocalActiveSpanSource; //导入依赖的package包/类
@Test
public void testWithTags() {
MetricsReporter reporter = Mockito.mock(MetricsReporter.class);
MockTracer tracer = new MockTracer(new ThreadLocalActiveSpanSource());
Tracer metricsTracer = Metrics.decorate(tracer, reporter);
ActiveSpan parent = metricsTracer.buildSpan("parent")
.withTag("booleanTag", true)
.withTag("numericTag", new Integer(100))
.startActive();
parent.deactivate();
List<MockSpan> spans = tracer.finishedSpans();
assertEquals(1, spans.size());
MockSpan span = spans.get(0);
Map<String, Object> tags = span.tags();
Object booleanTag = tags.get("booleanTag");
assertNotNull("Expected a tag named 'booleanTag'", booleanTag);
assertTrue("booleanTag should be a Boolean", booleanTag instanceof Boolean);
assertEquals("booleanTag should be true", true, booleanTag);
Object numericTag = tags.get("numericTag");
assertNotNull("Expected a tag named 'numericTag'", numericTag);
assertTrue("numericTag should be a Number", numericTag instanceof Number);
assertEquals("numericTag should be 100", 100, numericTag);
}
开发者ID:opentracing-contrib,项目名称:java-metrics,代码行数:29,代码来源:MetricsTest.java
示例3: testAsChildOf
import io.opentracing.util.ThreadLocalActiveSpanSource; //导入依赖的package包/类
@Test
public void testAsChildOf() {
MetricsReporter reporter = Mockito.mock(MetricsReporter.class);
MockTracer tracer = new MockTracer(new ThreadLocalActiveSpanSource());
Tracer metricsTracer = Metrics.decorate(tracer, reporter);
ActiveSpan parentSpan = metricsTracer.buildSpan("parent")
.withTag("spanName","parent")
.startActive();
parentSpan.setTag("additionalTag", "parent");
ActiveSpan childSpan = metricsTracer.buildSpan("child")
.asChildOf(parentSpan)
.withTag("spanName","child")
.startActive();
childSpan.setTag("additionalTag", "child");
childSpan.deactivate();
parentSpan.deactivate();
List<MockSpan> spans = tracer.finishedSpans();
assertEquals(2, spans.size());
MockSpan span1 = spans.get(0);
MockSpan span2 = spans.get(1);
MockSpan parent, child;
if (span1.operationName().equals("parent")) {
parent = span1;
child = span2;
} else {
parent = span2;
child = span1;
}
assertEquals("Child's parent id should be spanId of parent", child.parentId(), parent.context().spanId());
assertEquals(0, parent.parentId());
}
开发者ID:opentracing-contrib,项目名称:java-metrics,代码行数:38,代码来源:MetricsTest.java
示例4: testDefaultConfiguration
import io.opentracing.util.ThreadLocalActiveSpanSource; //导入依赖的package包/类
@Test
public void testDefaultConfiguration() {
MockTracer mockTracer = new MockTracer(new ThreadLocalActiveSpanSource(), Propagator.TEXT_MAP);
GlobalTracer.register(mockTracer);
Client client = ClientBuilder.newClient()
.register(ClientTracingFeature.class);
Response response = client.target(url("/hello"))
.request()
.get();
response.close();
Assert.assertEquals(1, mockTracer.finishedSpans().size());
}
开发者ID:opentracing-contrib,项目名称:java-jaxrs,代码行数:15,代码来源:AbstractClientTest.java
示例5: tracer
import io.opentracing.util.ThreadLocalActiveSpanSource; //导入依赖的package包/类
@Bean
public MockTracer tracer() {
return new MockTracer(new ThreadLocalActiveSpanSource());
}
开发者ID:opentracing-contrib,项目名称:java-spring-web,代码行数:5,代码来源:ServerTracingAutoConfigurationTest.java
示例6: testStandardUsage
import io.opentracing.util.ThreadLocalActiveSpanSource; //导入依赖的package包/类
@Test
public void testStandardUsage() {
Map<String,Object> sysTags = new HashMap<String,Object>();
sysTags.put("service", "TestService");
MetricsReporter reporter = Mockito.mock(MetricsReporter.class);
MockTracer tracer = new MockTracer(new ThreadLocalActiveSpanSource());
Tracer metricsTracer = Metrics.decorate(tracer, reporter);
ActiveSpan parent = metricsTracer.buildSpan("parent").withTag("spanName","parent").startActive();
parent.setTag("additionalTag", "parent");
ActiveSpan child = metricsTracer.buildSpan("child").withTag("spanName","child").startActive();
child.setTag("additionalTag", "child");
// Test ref counting works fine
ActiveSpan child2 = child.capture().activate();
child2.deactivate();
// Still should be ref to child span
assertEquals(0, tracer.finishedSpans().size());
child.deactivate();
assertEquals(1, tracer.finishedSpans().size());
parent.deactivate();
List<MockSpan> spans = tracer.finishedSpans();
assertEquals(2, spans.size());
Mockito.verify(reporter, Mockito.times(2)).reportSpan(spanDataCaptor.capture());
List<SpanData> captured = spanDataCaptor.getAllValues();
assertEquals(captured.size(), spans.size());
for (int i=0; i < spans.size(); i++) {
MockSpan span = spans.get(i);
assertEquals(span.operationName(), span.tags().get("spanName"));
assertEquals(span.operationName(), span.tags().get("additionalTag"));
}
assertTrue(captured.get(0).getDuration() < captured.get(1).getDuration());
assertEquals("child", captured.get(0).getOperationName());
assertEquals("parent", captured.get(1).getOperationName());
assertEquals(tracer.finishedSpans().get(0).tags(), captured.get(0).getTags());
assertEquals(tracer.finishedSpans().get(1).tags(), captured.get(1).getTags());
}
开发者ID:opentracing-contrib,项目名称:java-metrics,代码行数:50,代码来源:MetricsTest.java
示例7: testStandardUsage
import io.opentracing.util.ThreadLocalActiveSpanSource; //导入依赖的package包/类
@Test
public void testStandardUsage() {
Map<String,Object> sysTags = new HashMap<String,Object>();
sysTags.put("service", "TestService");
MetricsReporter reporter = Mockito.mock(MetricsReporter.class);
MockTracer tracer = new MockTracer(new ThreadLocalActiveSpanSource());
Tracer metricsTracer = Metrics.decorate(tracer, reporter);
ActiveSpan parent = metricsTracer.buildSpan("parent").withTag("spanName","parent").startActive();
parent.setTag("additionalTag", "parent");
ActiveSpan child = metricsTracer.buildSpan("child").withTag("spanName","child").startActive();
child.setTag("additionalTag", "child");
// Test ref counting works fine
ActiveSpan child2 = child.capture().activate();
child2.deactivate();
// Still should be ref to child span
assertEquals(0, tracer.finishedSpans().size());
child.deactivate();
assertEquals(1, tracer.finishedSpans().size());
parent.deactivate();
List<MockSpan> spans = tracer.finishedSpans();
assertEquals(2, spans.size());
Mockito.verify(reporter, Mockito.times(2)).reportSpan(spanCaptor.capture(), operationCaptor.capture(),
tagsCaptor.capture(), durationCaptor.capture());
List<BaseSpan<?>> capturedSpans = spanCaptor.getAllValues();
assertEquals(capturedSpans.size(), spans.size());
for (int i=0; i < spans.size(); i++) {
MockSpan span = spans.get(i);
assertEquals(span.operationName(), span.tags().get("spanName"));
assertEquals(span.operationName(), span.tags().get("additionalTag"));
assertEquals(span.context(), capturedSpans.get(i).context());
}
assertEquals(Arrays.asList("child","parent"), operationCaptor.getAllValues());
assertTrue(durationCaptor.getAllValues().get(0) < durationCaptor.getAllValues().get(1));
assertEquals(tracer.finishedSpans().get(0).tags(), tagsCaptor.getAllValues().get(0));
assertEquals(tracer.finishedSpans().get(1).tags(), tagsCaptor.getAllValues().get(1));
}
开发者ID:objectiser,项目名称:java-metrics-prototype,代码行数:51,代码来源:MetricsTracerTest.java
示例8: mockTracer
import io.opentracing.util.ThreadLocalActiveSpanSource; //导入依赖的package包/类
@Bean
public MockTracer mockTracer() {
resetGlobalTracer();
return new MockTracer(new ThreadLocalActiveSpanSource(), Propagator.TEXT_MAP);
}
开发者ID:opentracing-contrib,项目名称:java-spring-cloud,代码行数:6,代码来源:MockTracingConfiguration.java
注:本文中的io.opentracing.util.ThreadLocalActiveSpanSource类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论