Java Code Examples for io.jaegertracing.Configuration#SamplerConfiguration
The following examples show how to use
io.jaegertracing.Configuration#SamplerConfiguration .
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: JaegerStartupHookProvider.java From light-4j with Apache License 2.0 | 5 votes |
@Override public void onStartup() { // register the service instance to the Jaeger tracer agent and create a tracer object if it is enabled. if(jaegerConfig.isEnabled()) { Configuration.SamplerConfiguration samplerConfig = new Configuration.SamplerConfiguration().withType(jaegerConfig.getType()).withParam(jaegerConfig.getParam()); Configuration.ReporterConfiguration reporterConfig = new Configuration.ReporterConfiguration().withLogSpans(true); tracer = new Configuration(serverConfig.getServiceId()).withSampler(samplerConfig).withReporter(reporterConfig).getTracer(); } }
Example 2
Source File: TracingUtil.java From oxd with Apache License 2.0 | 5 votes |
private static Tracer createTracer(OxdServerConfiguration configuration, String componentName) { String tracerName = configuration.getTracer(); if (!configuration.getEnableTracing() || Strings.isNullOrEmpty(tracerName)) { return NoopTracerFactory.create(); } else if ("jaeger".equals(tracerName)) { Configuration.SamplerConfiguration samplerConfig = new Configuration.SamplerConfiguration() .withType(ConstSampler.TYPE) .withParam(1); Configuration.SenderConfiguration senderConfig = new Configuration.SenderConfiguration() .withAgentHost(configuration.getTracerHost()) .withAgentPort(configuration.getTracerPort()); Configuration.ReporterConfiguration reporterConfig = new Configuration.ReporterConfiguration() .withLogSpans(true) .withFlushInterval(1000) .withMaxQueueSize(10000) .withSender(senderConfig); return new Configuration(componentName) .withSampler(samplerConfig) .withReporter(reporterConfig) .getTracer(); } else if ("zipkin".equals(tracerName)) { OkHttpSender sender = OkHttpSender.create( "http://" + configuration.getTracerHost() + ":" + configuration.getTracerPort() + "/api/v1/spans"); Reporter<Span> reporter = AsyncReporter.builder(sender).build(); return BraveTracer.create(Tracing.newBuilder() .localServiceName(componentName) .spanReporter(reporter) .build()); } else { return NoopTracerFactory.create(); } }
Example 3
Source File: TracingContextCustomizer.java From camel-k-runtime with Apache License 2.0 | 4 votes |
public Configuration.SamplerConfiguration getSampler() { return sampler; }
Example 4
Source File: TracingContextCustomizer.java From camel-k-runtime with Apache License 2.0 | 4 votes |
public void setSampler(Configuration.SamplerConfiguration sampler) { this.sampler = sampler; }
Example 5
Source File: JaegerTracerConfigurator.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public void init(@SuppressWarnings({"rawtypes"})NamedList args) { Object host = args.get(AGENT_HOST); if (!(host instanceof String)) { throw new IllegalArgumentException("Expected a required string for param '" + AGENT_HOST + "'"); } Object portArg = args.get(AGENT_PORT); if (!(portArg instanceof Integer)) { throw new IllegalArgumentException("Expected a required int for param '" + AGENT_PORT + "'"); } int port = (Integer) portArg; Boolean logSpans = args.getBooleanArg(LOG_SPANS); if (logSpans == null) logSpans = true; Object flushIntervalArg = args.get(FLUSH_INTERVAL); if (flushIntervalArg != null && !(flushIntervalArg instanceof Integer)) { throw new IllegalArgumentException("Expected a required int for param '" + FLUSH_INTERVAL +"'"); } int flushInterval = flushIntervalArg == null ? 1000 : (Integer) flushIntervalArg; Object maxQueueArgs = args.get(MAX_QUEUE_SIZE); if (maxQueueArgs != null && !(maxQueueArgs instanceof Integer)) { throw new IllegalArgumentException("Expected a required int for param '" + MAX_QUEUE_SIZE +"'"); } int maxQueue = maxQueueArgs == null ? 10000 : (Integer) maxQueueArgs; Configuration.SamplerConfiguration samplerConfig = new Configuration.SamplerConfiguration() .withType(ConstSampler.TYPE) .withParam(1); Configuration.ReporterConfiguration reporterConfig = Configuration.ReporterConfiguration.fromEnv(); Configuration.SenderConfiguration senderConfig = reporterConfig.getSenderConfiguration() .withAgentHost(host.toString()) .withAgentPort(port); reporterConfig.withLogSpans(logSpans) .withFlushInterval(flushInterval) .withMaxQueueSize(maxQueue) .withSender(senderConfig); tracer = new Configuration("solr") .withSampler(samplerConfig) .withReporter(reporterConfig) .getTracer(); }
Example 6
Source File: JaegerTracer.java From carbon-apimgt with Apache License 2.0 | 4 votes |
@Override public Tracer getTracer(String serviceName) { String hostname = configuration.getFirstProperty(TracingConstants.JAEGER_CONFIG_HOST) != null ? configuration.getFirstProperty(TracingConstants.JAEGER_CONFIG_HOST) : TracingConstants.JAEGER_DEFAULT_HOST; int port = configuration.getFirstProperty(TracingConstants.JAEGER_CONFIG_PORT) != null ? Integer.parseInt(configuration.getFirstProperty(TracingConstants.JAEGER_CONFIG_PORT)) : TracingConstants.JAEGER_DEFAULT_PORT; String samplerType = configuration.getFirstProperty(TracingConstants.CONFIG_SAMPLER_TYPE) != null ? configuration.getFirstProperty(TracingConstants.CONFIG_SAMPLER_TYPE) : TracingConstants.DEFAULT_SAMPLER_TYPE; float samplerParam = configuration.getFirstProperty(TracingConstants.CONFIG_SAMPLER_PARAM) != null ? Float.parseFloat(configuration.getFirstProperty(TracingConstants.CONFIG_SAMPLER_PARAM)) : TracingConstants.DEFAULT_SAMPLER_PARAM; int reporterFlushInterval = configuration.getFirstProperty(TracingConstants.CONFIG_REPORTER_FLUSH_INTERVAL) != null ? Integer.parseInt(configuration.getFirstProperty(TracingConstants.CONFIG_REPORTER_FLUSH_INTERVAL)) : TracingConstants.DEFAULT_REPORTER_FLUSH_INTERVAL; int reporterBufferSize = configuration.getFirstProperty(TracingConstants.CONFIG_REPORTER_BUFFER_SIZE) != null ? Integer.parseInt(configuration.getFirstProperty(TracingConstants.CONFIG_REPORTER_BUFFER_SIZE)) : TracingConstants.DEFAULT_REPORTER_BUFFER_SIZE; boolean tracerLogEnabled = Boolean.parseBoolean(configuration.getFirstProperty(TracingConstants.CONFIG_TRACER_LOG_ENABLED) != null ? configuration.getFirstProperty(TracingConstants.CONFIG_TRACER_LOG_ENABLED) : TracingConstants.DEFAULT_TRACER_LOG_ENABLED); Configuration.SamplerConfiguration samplerConfig = new Configuration.SamplerConfiguration() .withType(samplerType) .withParam(samplerParam); Configuration.SenderConfiguration senderConfig = new Configuration.SenderConfiguration() .withAgentHost(hostname) .withAgentPort(port); Configuration.ReporterConfiguration reporterConfig = new Configuration.ReporterConfiguration() .withLogSpans(true) .withFlushInterval(reporterFlushInterval) .withMaxQueueSize(reporterBufferSize) .withSender(senderConfig); Tracer tracer = new Configuration(serviceName).withSampler(samplerConfig) .withReporter(reporterConfig).getTracer(); if (tracerLogEnabled) { Reporter reporter = new TracingReporter(LogFactory.getLog(TracingConstants.TRACER)); Tracer tracerR = new TracerR(tracer, reporter, new ThreadLocalScopeManager()); GlobalTracer.register(tracerR); return tracerR; } else { GlobalTracer.register(tracer); return tracer; } }