public static CountSampler countSampler(long frequency) { return new CountSampler(HTraceConfiguration.fromMap(Collections .singletonMap(CountSampler.SAMPLER_FREQUENCY_CONF_KEY, Long.toString(frequency)))); }
public AsyncSpanReceiver(HTraceConfiguration conf) { host = conf.get(DistributedTrace.TRACE_HOST_PROPERTY, host); if (host == null) { try { host = InetAddress.getLocalHost().getCanonicalHostName().toString(); } catch (UnknownHostException e) { host = "unknown"; } } service = conf.get(DistributedTrace.TRACE_SERVICE_PROPERTY, service); maxQueueSize = conf.getInt(QUEUE_SIZE, maxQueueSize); minSpanSize = conf.getInt(SPAN_MIN_MS, minSpanSize); int millis = conf.getInt(SEND_TIMER_MILLIS, 1000); timer.schedule(new TimerTask() { @Override public void run() { try { sendSpans(); } catch (Exception ex) { log.warn("Exception sending spans to destination", ex); } } }, millis, millis); }
/** * Set this builder back to defaults. Any previous calls to {@link #spanReceiverClass(String)} * are overridden by the value provided by configuration. * @return This instance */ public SpanReceiverBuilder reset() { this.logErrors = true; this.spanReceiverClass = this.conf.get(SPAN_RECEIVER_CONF_KEY); return this; }
public ProbabilitySampler(HTraceConfiguration conf) { this.threshold = Double.parseDouble(conf.get(SAMPLER_FRACTION_CONF_KEY)); }
public static ProbabilitySampler probabilitySampler(double fraction) { return new ProbabilitySampler(HTraceConfiguration.fromMap(Collections .singletonMap(ProbabilitySampler.SAMPLER_FRACTION_CONF_KEY, Double.toString(fraction)))); }
public ZooTraceClient(HTraceConfiguration conf) { super(conf); String keepers = conf.get(DistributedTrace.TRACER_ZK_HOST); if (keepers == null) throw new IllegalArgumentException("Must configure " + DistributedTrace.TRACER_ZK_HOST); int timeout = conf.getInt(DistributedTrace.TRACER_ZK_TIMEOUT, DEFAULT_TIMEOUT); zoo = new ZooReader(keepers, timeout); path = conf.get(DistributedTrace.TRACER_ZK_PATH, Constants.ZTRACERS); setInitialTraceHosts(); }
public CountSampler(HTraceConfiguration conf) { this.frequency = Long.parseLong(conf.get(SAMPLER_FREQUENCY_CONF_KEY), 10); }
@Override public Sampler<?> apply(ConfigurationAdapter conf) { // get the connection properties for the probability information Map<String, String> items = new HashMap<String, String>(); items.put(ProbabilitySampler.SAMPLER_FRACTION_CONF_KEY, conf.get(QueryServices.TRACING_PROBABILITY_THRESHOLD_ATTRIB, Double.toString(QueryServicesOptions.DEFAULT_TRACING_PROBABILITY_THRESHOLD))); return new ProbabilitySampler(HTraceConfiguration.fromMap(items)); } };
public ZooTraceClient(HTraceConfiguration conf) { super(conf); String keepers = conf.get(DistributedTrace.TRACER_ZK_HOST); if (keepers == null) throw new IllegalArgumentException("Must configure " + DistributedTrace.TRACER_ZK_HOST); int timeout = conf.getInt(DistributedTrace.TRACER_ZK_TIMEOUT, DEFAULT_TIMEOUT); zoo = new ZooReader(keepers, timeout); path = conf.get(DistributedTrace.TRACER_ZK_PATH, Constants.ZTRACERS); setInitialTraceHosts(); }
public int getInt(String key, int defaultVal) { String val = get(key); if (val == null || val.trim().isEmpty()) { return defaultVal; } try { return Integer.parseInt(val); } catch (NumberFormatException nfe) { throw new IllegalArgumentException("Bad value for '" + key + "': should be int"); } }
public static Sampler<?> getConfiguredSampler(TraceStatement traceStatement) { double samplingRate = traceStatement.getSamplingRate(); if (samplingRate >= 1.0) { return Sampler.ALWAYS; } else if (samplingRate < 1.0 && samplingRate > 0.0) { Map<String, String> items = new HashMap<String, String>(); items.put(ProbabilitySampler.SAMPLER_FRACTION_CONF_KEY, Double.toString(samplingRate)); return new ProbabilitySampler(HTraceConfiguration.fromMap(items)); } else { return Sampler.NEVER; } }
public AsyncSpanReceiver(HTraceConfiguration conf) { host = conf.get(DistributedTrace.TRACE_HOST_PROPERTY, host); if (host == null) { try { host = InetAddress.getLocalHost().getCanonicalHostName().toString(); } catch (UnknownHostException e) { host = "unknown"; } } service = conf.get(DistributedTrace.TRACE_SERVICE_PROPERTY, service); maxQueueSize = conf.getInt(QUEUE_SIZE, maxQueueSize); minSpanSize = conf.getInt(SPAN_MIN_MS, minSpanSize); int millis = conf.getInt(SEND_TIMER_MILLIS, 1000); timer.schedule(new TimerTask() { @Override public void run() { try { sendSpans(); } catch (Exception ex) { log.warn("Exception sending spans to destination", ex); } } }, millis, millis); }
public boolean getBoolean(String key, boolean defaultValue) { String value = get(key, String.valueOf(defaultValue)).trim().toLowerCase(); if ("true".equals(value)) { return true; } else if ("false".equals(value)) { return false; } LOG.warn("Expected boolean for key [" + key + "] instead got [" + value + "]."); return defaultValue; }
public CountSampler(long frequency) { super(HTraceConfiguration.fromMap(Collections .singletonMap(CountSampler.SAMPLER_FREQUENCY_CONF_KEY, Long.toString(frequency)))); } }
public LocalFileSpanReceiver(HTraceConfiguration conf) { this.executorTerminationTimeoutDuration = EXECUTOR_TERMINATION_TIMEOUT_DURATION_DEFAULT; int capacity = conf.getInt(CAPACITY_KEY, CAPACITY_DEFAULT); this.file = conf.get(PATH_KEY); if (file == null || file.isEmpty()) { throw new IllegalArgumentException("must configure " + PATH_KEY); } this.executor = new ThreadPoolExecutor(1, 1, 0, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(capacity)); try { this.fwriter = new FileWriter(this.file, true); } catch (IOException ioe) { throw new RuntimeException(ioe); } this.bwriter = new BufferedWriter(fwriter); }
public Sampler build() { String str = conf.get(SAMPLER_CONF_KEY); if (str.isEmpty()) { return NeverSampler.INSTANCE;
public ProbabilitySampler(double d) { super(HTraceConfiguration.fromMap(Collections .singletonMap(ProbabilitySampler.SAMPLER_FRACTION_CONF_KEY, Double.toString(d)))); } }
@Test public void testWrappedHadoopConf() { String key = "sampler"; String value = "ProbabilitySampler"; Configuration conf = new Configuration(); conf.set(TEST_PREFIX + key, value); HTraceConfiguration wrapped = TraceUtils.wrapHadoopConf(TEST_PREFIX, conf); assertEquals(value, wrapped.get(key)); }
public CountSampler(long frequency) { super(HTraceConfiguration.fromMap(Collections .singletonMap(CountSampler.SAMPLER_FREQUENCY_CONF_KEY, Long.toString(frequency)))); }
@Test public void testWrappedHadoopConf() { String key = "sampler"; String value = "ProbabilitySampler"; Configuration conf = new Configuration(); conf.set(TEST_PREFIX + key, value); HTraceConfiguration wrapped = TraceUtils.wrapHadoopConf(TEST_PREFIX, conf); assertEquals(value, wrapped.get(key)); }