本文整理汇总了Java中io.opentracing.NoopTracerFactory.create方法的典型用法代码示例。如果您正苦于以下问题:Java NoopTracerFactory.create方法的具体用法?Java NoopTracerFactory.create怎么用?Java NoopTracerFactory.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.opentracing.NoopTracerFactory
的用法示例。
在下文中一共展示了NoopTracerFactory.create方法的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;
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
示例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();
}
示例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;
}
示例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();
}
示例10: 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();
}
示例11: 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);
}
示例12: 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()));
}
示例13: 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);
}
示例14: getTracer
import io.opentracing.NoopTracerFactory; //导入方法依赖的package包/类
@Override
public Tracer getTracer() {
return NoopTracerFactory.create();
}
示例15: DefaultLoggerTracer
import io.opentracing.NoopTracerFactory; //导入方法依赖的package包/类
/**
* No args constructor used by Service Loader
*/
public DefaultLoggerTracer() {
super(NoopTracerFactory.create(), new Slf4jReporter(LoggerFactory.getLogger("tracer"), true));
}