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

The following examples show how to use io.jaegertracing.Configuration#getTracer() . 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: JaegerConfigurator.java    From dremio-oss with Apache License 2.0 6 votes vote down vote up
@Override
public Tracer getTracer() {
  SamplerConfiguration sampleConf = SamplerConfiguration.fromEnv()
    .withType(type);

  if (param != null) {
    sampleConf.withParam(param);
  }

  ReporterConfiguration reportConf = ReporterConfiguration.fromEnv()
    .withLogSpans(logSpans);

  Configuration config = new Configuration(name)
    .withReporter(reportConf)
    .withSampler(sampleConf);

  // If the user gets rid of their tracer config and then puts it back, we want to get a fresh tracer since the old
  // one will be closed.
  return config.getTracer();
}
 
Example 2
Source File: JaegerTraceFactory.java    From joyrpc with Apache License 2.0 5 votes vote down vote up
public JaegerTraceFactory() {
    Map<String, Object> global = GlobalContext.getContext();
    Object obj = global.get(TRACE_JAEGER);
    if (obj instanceof JaegerTracer) {
        //判断是否有全局的变量
        tracer = (JaegerTracer) obj;
    } else {
        Parametric parametric = Variable.VARIABLE;
        Configuration configuration = new Configuration(parametric.getString("appService", KEY_APPNAME, "unknown"));
        configuration.withSampler(buildSamplerConfiguration(parametric));
        configuration.withReporter(buildReporterConfiguration(parametric));
        tracer = configuration.getTracer();
    }
}
 
Example 3
Source File: Tracing.java    From opentracing-tutorial with Apache License 2.0 5 votes vote down vote up
public static JaegerTracer init(String service) {
    SamplerConfiguration samplerConfig = SamplerConfiguration.fromEnv()
            .withType(ConstSampler.TYPE)
            .withParam(1);

    ReporterConfiguration reporterConfig = ReporterConfiguration.fromEnv()
            .withLogSpans(true);

    Configuration config = new Configuration(service)
            .withSampler(samplerConfig)
            .withReporter(reporterConfig);

    return config.getTracer();
}