本文整理汇总了Java中io.opentracing.mock.MockSpan.MockContext方法的典型用法代码示例。如果您正苦于以下问题:Java MockSpan.MockContext方法的具体用法?Java MockSpan.MockContext怎么用?Java MockSpan.MockContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.opentracing.mock.MockSpan
的用法示例。
在下文中一共展示了MockSpan.MockContext方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extract_second_no_context
import io.opentracing.mock.MockSpan; //导入方法依赖的package包/类
@Test
public void extract_second_no_context() {
MockSpan span = mockTracer.buildSpan("first").start();
Headers headers = new RecordHeaders();
assertTrue(headers.toArray().length == 0);
// inject first
TracingKafkaUtils.inject(span.context(), headers, mockTracer);
int headersLength = headers.toArray().length;
assertTrue(headersLength > 0);
// check second
MockSpan.MockContext spanContext2 = (MockContext) TracingKafkaUtils
.extractSpanContext(headers, mockTracer);
assertNull(spanContext2);
}
示例2: extract
import io.opentracing.mock.MockSpan; //导入方法依赖的package包/类
@Test
public void extract() {
MockSpan span = mockTracer.buildSpan("test").start();
Headers headers = new RecordHeaders();
TracingKafkaUtils.inject(span.context(), headers, mockTracer);
MockSpan.MockContext spanContext = (MockSpan.MockContext) TracingKafkaUtils
.extract(headers, mockTracer);
assertEquals(span.context().spanId(), spanContext.spanId());
assertEquals(span.context().traceId(), spanContext.traceId());
}
示例3: extract_no_context
import io.opentracing.mock.MockSpan; //导入方法依赖的package包/类
@Test
public void extract_no_context() {
Headers headers = new RecordHeaders();
// first
MockSpan.MockContext spanContext = (MockSpan.MockContext) TracingKafkaUtils
.extract(headers, mockTracer);
assertNull(spanContext);
// second
MockSpan.MockContext spanContext2 = (MockContext) TracingKafkaUtils
.extractSpanContext(headers, mockTracer);
assertNull(spanContext2);
}
示例4: inject_and_extract_two_contexts
import io.opentracing.mock.MockSpan; //导入方法依赖的package包/类
@Test
public void inject_and_extract_two_contexts() {
MockSpan span = mockTracer.buildSpan("first").start();
Headers headers = new RecordHeaders();
assertTrue(headers.toArray().length == 0);
// inject first
TracingKafkaUtils.inject(span.context(), headers, mockTracer);
int headersLength = headers.toArray().length;
assertTrue(headersLength > 0);
// inject second
MockSpan span2 = mockTracer.buildSpan("second").asChildOf(span.context()).start();
TracingKafkaUtils.injectSecond(span2.context(), headers, mockTracer);
assertTrue(headers.toArray().length > headersLength);
// check first
MockSpan.MockContext spanContext = (MockSpan.MockContext) TracingKafkaUtils
.extract(headers, mockTracer);
assertEquals(span.context().spanId(), spanContext.spanId());
assertEquals(span.context().traceId(), spanContext.traceId());
// check second
MockSpan.MockContext spanContext2 = (MockContext) TracingKafkaUtils
.extractSpanContext(headers, mockTracer);
assertEquals(span2.context().spanId(), spanContext2.spanId());
assertEquals(span2.context().traceId(), spanContext2.traceId());
assertEquals(spanContext.traceId(), spanContext2.traceId());
assertNotEquals(spanContext.spanId(), spanContext2.spanId());
}
示例5: extractContextFromManager
import io.opentracing.mock.MockSpan; //导入方法依赖的package包/类
@Test
public void extractContextFromManager() {
MockSpan span = mockTracer.buildSpan("test").start();
mockTracer.scopeManager().activate(span, true);
MockSpan.MockContext context = (MockSpan.MockContext) TracingMessageUtils
.extract(new ActiveMQTextMessage(), mockTracer);
assertNotNull(context);
assertEquals(span.context().spanId(), context.spanId());
}
示例6: extractContextFromProperties
import io.opentracing.mock.MockSpan; //导入方法依赖的package包/类
@Test
public void extractContextFromProperties() {
MockSpan span = mockTracer.buildSpan("test").start();
ActiveMQTextMessage message = new ActiveMQTextMessage();
TracingMessageUtils.inject(span, message, mockTracer);
MockSpan.MockContext context = (MockSpan.MockContext) TracingMessageUtils
.extract(message, mockTracer);
assertNotNull(context);
assertEquals(span.context().spanId(), context.spanId());
}