当前位置: 首页>>代码示例>>Java>>正文


Java MockSpan.MockContext方法代码示例

本文整理汇总了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);
}
 
开发者ID:opentracing-contrib,项目名称:java-kafka-client,代码行数:17,代码来源:TracingKafkaUtilsTest.java

示例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());
}
 
开发者ID:opentracing-contrib,项目名称:java-kafka-client,代码行数:13,代码来源:TracingKafkaUtilsTest.java

示例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);
}
 
开发者ID:opentracing-contrib,项目名称:java-kafka-client,代码行数:15,代码来源:TracingKafkaUtilsTest.java

示例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());
}
 
开发者ID:opentracing-contrib,项目名称:java-kafka-client,代码行数:31,代码来源:TracingKafkaUtilsTest.java

示例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());
}
 
开发者ID:opentracing-contrib,项目名称:java-jms,代码行数:10,代码来源:TracingMessageUtilsTest.java

示例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());
}
 
开发者ID:opentracing-contrib,项目名称:java-jms,代码行数:11,代码来源:TracingMessageUtilsTest.java


注:本文中的io.opentracing.mock.MockSpan.MockContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。