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


Java NoopTracerFactory类代码示例

本文整理汇总了Java中io.opentracing.NoopTracerFactory的典型用法代码示例。如果您正苦于以下问题:Java NoopTracerFactory类的具体用法?Java NoopTracerFactory怎么用?Java NoopTracerFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NoopTracerFactory类属于io.opentracing包,在下文中一共展示了NoopTracerFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTracer

import io.opentracing.NoopTracerFactory; //导入依赖的package包/类
/**
 * This method provides tracer if user did not specify any tracer bean.
 * <p>
 * The order of getting the tracer is:
 * <ol>
 *     <li>Tracer registered in {@link GlobalTracer#register(Tracer)}</li>
 *     <li>Tracer resolved from {@link TracerResolver#resolve()}</li>
 *     <li>Default tracer, which is {@link io.opentracing.NoopTracer}</li>
 * </ol>
 * @return tracer
 */
@Bean
@ConditionalOnMissingBean(Tracer.class)
public Tracer getTracer() {
    Tracer tracer;
    if (GlobalTracer.isRegistered()) {
        log.warn("GlobalTracer is already registered. For consistency it is best practice to provide " +
                "a Tracer bean instead of manually registering it with the GlobalTracer");
        tracer = GlobalTracer.get();
    } else {
        tracer = TracerResolver.resolveTracer();
        if (tracer == null) {
            // WARNING: Don't return GlobalTracer.get() as this will result in a
            // stack overflow if the returned tracer is subsequently wrapped by a
            // BeanPostProcessor. The post processed tracer would then be registered
            // with the {@link GlobalTracer) (via the {@link TracerRegisterAutoConfiguration})
            // resulting in the wrapper both wrapping the GlobalTracer, as well as being
            // the tracer used by the GlobalTracer.
            tracer = NoopTracerFactory.create();
        }
    }
    log.warn("Tracer bean is not configured! Switching to " + tracer);
    return tracer;
}
 
开发者ID:opentracing-contrib,项目名称:java-spring-web,代码行数:35,代码来源:TracerAutoConfiguration.java

示例2: getJaegerTracer

import io.opentracing.NoopTracerFactory; //导入依赖的package包/类
static Tracer getJaegerTracer(String serviceName) {
  try {
    return new com.uber.jaeger.Configuration(
        serviceName,
        new com.uber.jaeger.Configuration.SamplerConfiguration("const", 1),
        new com.uber.jaeger.Configuration.ReporterConfiguration(
            true,
            "docker-vm",
            6831,
            1000,   // flush interval in milliseconds
            10000)  /*max buffered Spans*/)
        .getTracer();
  } catch (Exception e) {
    e.printStackTrace();
    return NoopTracerFactory.create();
  }
}
 
开发者ID:jeqo,项目名称:talk-observing-distributed-systems,代码行数:18,代码来源:TracerBuilder.java

示例3: getZipkinTracer

import io.opentracing.NoopTracerFactory; //导入依赖的package包/类
static Tracer getZipkinTracer(String serviceName) {
  try {
    // Configure a reporter, which controls how often spans are sent
    //   (the dependency is io.zipkin.reporter2:zipkin-sender-okhttp3)
    final OkHttpSender sender = OkHttpSender.create("http://docker-vm:9411/api/v2/spans");
    final AsyncReporter<Span> spanReporter = AsyncReporter.create(sender);

    // Now, create a Brave tracing component with the service name you want to see in Zipkin.
    //   (the dependency is io.zipkin.brave:brave)
    final Tracing braveTracing =
        Tracing.newBuilder()
            .localServiceName(serviceName)
            .spanReporter(spanReporter)
            .build();

    // use this to create an OpenTracing Tracer
    return BraveTracer.create(braveTracing);
  } catch (Exception e) {
    e.printStackTrace();
    return NoopTracerFactory.create();
  }
}
 
开发者ID:jeqo,项目名称:talk-observing-distributed-systems,代码行数:23,代码来源:TracerBuilder.java

示例4: getTracer

import io.opentracing.NoopTracerFactory; //导入依赖的package包/类
private Tracer getTracer() {
  try {
    return new com.uber.jaeger.Configuration(
        getName(),
        new com.uber.jaeger.Configuration.SamplerConfiguration("const", 1),
        new com.uber.jaeger.Configuration.ReporterConfiguration(
            true,
            "tracing-jaeger-agent",
            6831,
            1000,   // flush interval in milliseconds
            10000)  /*max buffered Spans*/)
        .getTracer();
  } catch (Exception e) {
    e.printStackTrace();
    return NoopTracerFactory.create();
  }
}
 
开发者ID:jeqo,项目名称:talk-observing-distributed-systems,代码行数:18,代码来源:SearchServiceApplication.java

示例5: getTracer

import io.opentracing.NoopTracerFactory; //导入依赖的package包/类
private Tracer getTracer() {
  try {
    return new com.uber.jaeger.Configuration(
        getName(),
        new com.uber.jaeger.Configuration.SamplerConfiguration("const", 1), // 100%
        new com.uber.jaeger.Configuration.ReporterConfiguration(
            true,
            "tracing-jaeger-agent",
            6831,
            1000,   // flush interval in milliseconds
            10000)  /*max buffered Spans*/)
        .getTracer();
  } catch (Exception e) {
    e.printStackTrace();
    return NoopTracerFactory.create();
  }
}
 
开发者ID:jeqo,项目名称:talk-observing-distributed-systems,代码行数:18,代码来源:IndexerServiceApplication.java

示例6: loadTracer

import io.opentracing.NoopTracerFactory; //导入依赖的package包/类
/**
 * Find a {@link Tracer} implementation.
 *
 * @return {@link Tracer} implementation.
 */
public static Tracer loadTracer() {
    try {
        Iterator<Tracer> tracers = ServiceLoader.load(Tracer.class).iterator();
        if (tracers.hasNext()) {
            Tracer tracer = tracers.next();
            if (!tracers.hasNext()) {
                return tracer;
            }
            LOGGER.log(Level.WARNING, "More than one Tracer service implementation found. " + "Falling back to NoopTracer implementation.");
        }
    } catch (Exception ex) {
        LOGGER.log(Level.SEVERE, ex.getLocalizedMessage());
    }
    return NoopTracerFactory.create();
}
 
开发者ID:opentracing-contrib,项目名称:java-hprose,代码行数:21,代码来源:TracerLoader.java

示例7: lightStepTracer

import io.opentracing.NoopTracerFactory; //导入依赖的package包/类
@Bean
public Tracer lightStepTracer() {
  try {
    return new JRETracer(
        new OptionsBuilder()
            .withAccessToken("bla-bla-bla")
            .withComponentName("spring-cloud")
            .build()
    );
  } catch (Exception e) {
    logger.error("Failed to init tracer", e);
  }
  return NoopTracerFactory.create();
}
 
开发者ID:malafeev,项目名称:spring-cloud-opentracing,代码行数:15,代码来源:ServiceApp2.java

示例8: createHttpClientWrapper

import io.opentracing.NoopTracerFactory; //导入依赖的package包/类
protected HttpClientWrapper createHttpClientWrapper() {
    int port = locateTargetServicePort();
    serviceEndpoint = new ServiceEndpoint(new ScheduledThreadPoolExecutor(1),
            "localhost:" + port, "");
    HttpClientWrapper retval = new HttpClientWrapper(new ServiceProperties(), createHttpClient(),
            null, NoopTracerFactory.create());
    retval.setLoadBalancer(this);
    return retval;
}
 
开发者ID:Sixt,项目名称:ja-micro,代码行数:10,代码来源:ServiceImpersonatorLoadBalancer.java

示例9: tracer

import io.opentracing.NoopTracerFactory; //导入依赖的package包/类
@Produces
@Singleton
public Tracer tracer() {
    String jaegerURL = System.getenv("JAEGER_SERVER_HOSTNAME");
    if (jaegerURL != null) {
        log.info("Using Jaeger tracer");
        return jaegerTracer(jaegerURL);
    }

    log.info("Using Noop tracer");
    return NoopTracerFactory.create();

}
 
开发者ID:xstefank,项目名称:lra-service,代码行数:14,代码来源:BeanConfiguration.java

示例10: resetGlobalTracer

import io.opentracing.NoopTracerFactory; //导入依赖的package包/类
private static void resetGlobalTracer() {
  try {
    Field globalTracerField = GlobalTracer.class.getDeclaredField("tracer");
    globalTracerField.setAccessible(true);
    globalTracerField.set(null, NoopTracerFactory.create());
    globalTracerField.setAccessible(false);
  } catch (Exception e) {
    throw new RuntimeException("Error reflecting globalTracer: " + e.getMessage(), e);
  }
}
 
开发者ID:opentracing-contrib,项目名称:java-spring-cloud,代码行数:11,代码来源:MockTracingConfiguration.java

示例11: tracer

import io.opentracing.NoopTracerFactory; //导入依赖的package包/类
@Bean
public Tracer tracer() {
    String jaegerURL = System.getenv("JAEGER_SERVER_HOSTNAME");
    if (jaegerURL != null) {
        log.info("Using Jaeger tracer");
        return jaegerTracer(jaegerURL);
    }

    log.info("Using Noop tracer");
    return NoopTracerFactory.create();
}
 
开发者ID:redhat-helloworld-msa,项目名称:ola,代码行数:12,代码来源:TracingConfiguration.java

示例12: initTracing

import io.opentracing.NoopTracerFactory; //导入依赖的package包/类
@Override
protected void initTracing(ServletContextHandler context) {
    client.register(new Builder(mockTracer).build());

    Tracer serverTracer = NoopTracerFactory.create();
    ServerTracingDynamicFeature serverTracingBuilder =
            new ServerTracingDynamicFeature.Builder(serverTracer)
                    .build();

    context.setAttribute(TRACER_ATTRIBUTE, serverTracer);
    context.setAttribute(CLIENT_ATTRIBUTE, ClientBuilder.newClient());
    context.setAttribute(SERVER_TRACING_FEATURE, serverTracingBuilder);
}
 
开发者ID:opentracing-contrib,项目名称:java-jaxrs,代码行数:14,代码来源:AbstractClientTest.java

示例13: resetGlobalTracer

import io.opentracing.NoopTracerFactory; //导入依赖的package包/类
@AfterClass
public static void resetGlobalTracer() {
    try {
        Field globalTracerField = GlobalTracer.class.getDeclaredField("tracer");
        globalTracerField.setAccessible(true);
        globalTracerField.set(null, NoopTracerFactory.create());
        globalTracerField.setAccessible(false);
    } catch (Exception e) {
        throw new RuntimeException("Error resetting " + GlobalTracer.class, e);
    }
}
 
开发者ID:opentracing-contrib,项目名称:java-jaxrs,代码行数:12,代码来源:AbstractJettyTest.java

示例14: before

import io.opentracing.NoopTracerFactory; //导入依赖的package包/类
@Before
public void before() {
  Channel channelWithAttributes = mockChannelWithAttributes();
  when(ctx.channel()).thenReturn(channelWithAttributes);
  when(ctx.fireChannelRead(any(TransportRequest.class)))
      .then(
          invocation -> {
            TransportRequest req = TransportRequest.class.cast(invocation.getArgument(0));
            resultTester = req.getBody().accumulate().test();
            return invocation.getMock();
          });
  decoder =
      new HttpTransportDecoder<>(
          new TransportRequestDecoderConfiguration(NoopTracerFactory.create()));
}
 
开发者ID:yarpc,项目名称:yarpc-java,代码行数:16,代码来源:TransportRequestDecoderTest.java

示例15: before

import io.opentracing.NoopTracerFactory; //导入依赖的package包/类
@Before
public void before() throws Exception {
  encoderConfig =
      new TransportRequestEncoderConfiguration(
          new URL("http://test.uber.internal:12345/foo"), NoopTracerFactory.create());
  encoder = new HttpTransportEncoder<>(encoderConfig);
}
 
开发者ID:yarpc,项目名称:yarpc-java,代码行数:8,代码来源:TransportRequestEncoderTest.java


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