Java Code Examples for io.jaegertracing.Configuration#fromEnv()

The following examples show how to use io.jaegertracing.Configuration#fromEnv() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TracingConfig.java    From Mastering-Distributed-Tracing with MIT License 6 votes vote down vote up
@Bean
public io.opentracing.Tracer tracer(CollectorRegistry collector) {
    Configuration configuration = Configuration.fromEnv(app.name);
    Tracer jaegerTracer = configuration.getTracerBuilder() //
            .withSampler(new ConstSampler(true)) //
            .withScopeManager(new MDCScopeManager()) //
            .build();

    PrometheusMetricsReporter reporter = PrometheusMetricsReporter //
            .newMetricsReporter() //
            .withCollectorRegistry(collector) //
            .withConstLabel("service", app.name) //
            .withBaggageLabel("callpath", "") //
            .build();
    return io.opentracing.contrib.metrics.Metrics.decorate(jaegerTracer, reporter);
}
 
Example 2
Source File: TracingUtil.java    From hadoop-ozone with Apache License 2.0 5 votes vote down vote up
/**
 * Initialize the tracing with the given service name.
 */
public static void initTracing(
    String serviceName, ConfigurationSource conf) {
  if (!GlobalTracer.isRegistered() && isTracingEnabled(conf)) {
    Configuration config = Configuration.fromEnv(serviceName);
    JaegerTracer tracer = config.getTracerBuilder()
        .registerExtractor(StringCodec.FORMAT, new StringCodec())
        .registerInjector(StringCodec.FORMAT, new StringCodec())
        .build();
    GlobalTracer.register(tracer);
  }
}
 
Example 3
Source File: MeteredTracerProvider.java    From che with Eclipse Public License 2.0 5 votes vote down vote up
@Inject
public MeteredTracerProvider(Set<MetricsReporter> metricsReporter) {
  MicrometerMetricsFactory internalMetricsFactory = new MicrometerMetricsFactory();
  Configuration configuration = Configuration.fromEnv();
  Tracer tracer =
      configuration.getTracerBuilder().withMetricsFactory(internalMetricsFactory).build();

  this.tracerProvider = new TracerProvider(Metrics.decorate(tracer, metricsReporter));
}