private static synchronized void loadSpanReceivers(Configuration conf) { if (!receivers.isEmpty()) { log.info("Already loaded span receivers, enable tracing does not need to be called again"); return; } String[] receiverNames = conf.getTrimmedStrings(Property.TRACE_SPAN_RECEIVERS.toString()); if (receiverNames == null || receiverNames.length == 0) { return; } for (String className : receiverNames) { SpanReceiverBuilder builder = new SpanReceiverBuilder(wrapHadoopConf(conf)); SpanReceiver rcvr = builder.spanReceiverClass(className.trim()).build(); if (rcvr == null) { log.warn("Failed to load SpanReceiver {}", className); } else { receivers.add(rcvr); log.debug("SpanReceiver {} was loaded successfully.", className); } } for (SpanReceiver rcvr : receivers) { org.apache.htrace.Trace.addReceiver(rcvr); } }
/** * Add the phoenix span receiver so we can log the traces. We have a single trace source for the * whole JVM */ public synchronized static void addTraceMetricsSource() { try { QueryServicesOptions options = QueryServicesOptions.withDefaults(); if (!initialized && options.isTracingEnabled()) { traceSpanReceiver = new TraceSpanReceiver(); Trace.addReceiver(traceSpanReceiver); TraceWriter traceWriter = new TraceWriter(options.getTableName(), options.getTracingThreadPoolSize(), options.getTracingBatchSize()); traceWriter.start(); } } catch (RuntimeException e) { LOG.warn("Tracing will outputs will not be written to any metrics sink! No " + "TraceMetricsSink found on the classpath", e); } catch (IllegalAccessError e) { // This is an issue when we have a class incompatibility error, such as when running // within SquirrelSQL which uses an older incompatible version of commons-collections. // Seeing as this only results in disabling tracing, we swallow this exception and just // continue on without tracing. LOG.warn("Class incompatibility while initializing metrics, metrics will be disabled", e); } initialized = true; }
@Before public void setup() { tracingTableName = "TRACING_" + generateUniqueName(); traceSpanReceiver = new TraceSpanReceiver(); Trace.addReceiver(traceSpanReceiver); testTraceWriter = new TestTraceWriter(tracingTableName, defaultTracingThreadPoolForTest, defaultTracingBatchSizeForTest); }
/** * For PHOENIX-1126, Phoenix originally assumed all the annotation values were integers, * but HBase writes some strings as well, so we need to be able to handle that too */ @Test public void testNonIntegerAnnotations(){ Span span = getSpan(); // make sure its less than the length of an integer byte[] value = Bytes.toBytes("a"); byte[] someInt = Bytes.toBytes(1); assertTrue(someInt.length > value.length); // an annotation that is not an integer span.addKVAnnotation(Bytes.toBytes("key"), value); // Create the sink and write the span TraceSpanReceiver source = new TraceSpanReceiver(); Trace.addReceiver(source); Tracer.getInstance().deliver(span); assertTrue(source.getNumSpans() == 1); }
@Test public void testIntegerAnnotations(){ Span span = getSpan(); // add annotation through the phoenix interfaces TracingUtils.addAnnotation(span, "message", 10); TraceSpanReceiver source = new TraceSpanReceiver(); Trace.addReceiver(source); Tracer.getInstance().deliver(span); assertTrue(source.getNumSpans() == 1); }
try { SpanReceiver rcvr = loadInstance(className, EMPTY); Trace.addReceiver(rcvr); receivers.put(highestId++, rcvr); LOG.info("Loaded SpanReceiver " + className + " successfully.");
try { SpanReceiver rcvr = loadInstance(className, EMPTY); Trace.addReceiver(rcvr); receivers.put(highestId++, rcvr); LOG.info("Loaded SpanReceiver " + className + " successfully.");
public synchronized long addSpanReceiver(SpanReceiverInfo info) throws IOException { StringBuilder configStringBuilder = new StringBuilder(); String prefix = ""; for (ConfigurationPair pair : info.configPairs) { configStringBuilder.append(prefix).append(pair.getKey()). append(" = ").append(pair.getValue()); prefix = ", "; } SpanReceiver rcvr = null; try { rcvr = loadInstance(info.getClassName(), info.configPairs); } catch (IOException e) { LOG.info("Failed to add SpanReceiver " + info.getClassName() + " with configuration " + configStringBuilder.toString(), e); throw e; } catch (RuntimeException e) { LOG.info("Failed to add SpanReceiver " + info.getClassName() + " with configuration " + configStringBuilder.toString(), e); throw e; } Trace.addReceiver(rcvr); long newId = highestId++; receivers.put(newId, rcvr); LOG.info("Successfully added SpanReceiver " + info.getClassName() + " with configuration " + configStringBuilder.toString()); return newId; }
public synchronized long addSpanReceiver(SpanReceiverInfo info) throws IOException { StringBuilder configStringBuilder = new StringBuilder(); String prefix = ""; for (ConfigurationPair pair : info.configPairs) { configStringBuilder.append(prefix).append(pair.getKey()). append(" = ").append(pair.getValue()); prefix = ", "; } SpanReceiver rcvr = null; try { rcvr = loadInstance(info.getClassName(), info.configPairs); } catch (IOException e) { LOG.info("Failed to add SpanReceiver " + info.getClassName() + " with configuration " + configStringBuilder.toString(), e); throw e; } catch (RuntimeException e) { LOG.info("Failed to add SpanReceiver " + info.getClassName() + " with configuration " + configStringBuilder.toString(), e); throw e; } Trace.addReceiver(rcvr); long newId = highestId++; receivers.put(newId, rcvr); LOG.info("Successfully added SpanReceiver " + info.getClassName() + " with configuration " + configStringBuilder.toString()); return newId; }
private static synchronized void loadSpanReceivers(Configuration conf) { if (!receivers.isEmpty()) { log.info("Already loaded span receivers, enable tracing does not need to be called again"); return; } String[] receiverNames = conf.getTrimmedStrings(Property.TRACE_SPAN_RECEIVERS.toString()); if (receiverNames == null || receiverNames.length == 0) { return; } for (String className : receiverNames) { SpanReceiverBuilder builder = new SpanReceiverBuilder(wrapHadoopConf(conf)); SpanReceiver rcvr = builder.spanReceiverClass(className.trim()).build(); if (rcvr == null) { log.warn("Failed to load SpanReceiver " + className); } else { receivers.add(rcvr); log.info("SpanReceiver " + className + " was loaded successfully."); } } for (SpanReceiver rcvr : receivers) { org.apache.htrace.Trace.addReceiver(rcvr); } }
public synchronized long addSpanReceiver(SpanReceiverInfo info) throws IOException { StringBuilder configStringBuilder = new StringBuilder(); String prefix = ""; for (ConfigurationPair pair : info.configPairs) { configStringBuilder.append(prefix).append(pair.getKey()). append(" = ").append(pair.getValue()); prefix = ", "; } SpanReceiver rcvr = null; try { rcvr = loadInstance(info.getClassName(), info.configPairs); } catch (IOException e) { LOG.info("Failed to add SpanReceiver " + info.getClassName() + " with configuration " + configStringBuilder.toString(), e); throw e; } catch (RuntimeException e) { LOG.info("Failed to add SpanReceiver " + info.getClassName() + " with configuration " + configStringBuilder.toString(), e); throw e; } Trace.addReceiver(rcvr); long newId = highestId++; receivers.put(newId, rcvr); LOG.info("Successfully added SpanReceiver " + info.getClassName() + " with configuration " + configStringBuilder.toString()); return newId; }
confMap.put(AsyncSpanReceiver.SEND_TIMER_MILLIS, "1000"); confMap.put(AsyncSpanReceiver.QUEUE_SIZE, "5000"); Trace.addReceiver(new ZooTraceClient(HTraceConfiguration.fromMap(confMap))); } catch (IOException e) { log.error("Unable to initialize distributed tracing system: " + e.getMessage(), e);
/** * Reads the names of classes specified in the {@code hbase.trace.spanreceiver.classes} property * and instantiates and registers them with the Tracer. * */ public void loadSpanReceivers() { String[] receiverNames = conf.getStrings(SPAN_RECEIVERS_CONF_KEY); if (receiverNames == null || receiverNames.length == 0) { return; } SpanReceiverBuilder builder = new SpanReceiverBuilder(new HBaseHTraceConfiguration(conf)); for (String className : receiverNames) { className = className.trim(); SpanReceiver receiver = builder.spanReceiverClass(className).build(); if (receiver != null) { receivers.add(receiver); LOG.info("SpanReceiver " + className + " was loaded successfully."); } } for (SpanReceiver rcvr : receivers) { Trace.addReceiver(rcvr); } }
try { SpanReceiver rcvr = loadInstance(className, EMPTY); Trace.addReceiver(rcvr); receivers.put(highestId++, rcvr); LOG.info("Loaded SpanReceiver " + className + " successfully.");
/** * Add the phoenix span receiver so we can log the traces. We have a single trace source for the * whole JVM */ public synchronized static void addTraceMetricsSource() { try { QueryServicesOptions options = QueryServicesOptions.withDefaults(); if (!initialized && options.isTracingEnabled()) { traceSpanReceiver = new TraceSpanReceiver(); Trace.addReceiver(traceSpanReceiver); TraceWriter traceWriter = new TraceWriter(options.getTableName(), options.getTracingThreadPoolSize(), options.getTracingBatchSize()); traceWriter.start(); } } catch (RuntimeException e) { LOG.warn("Tracing will outputs will not be written to any metrics sink! No " + "TraceMetricsSink found on the classpath", e); } catch (IllegalAccessError e) { // This is an issue when we have a class incompatibility error, such as when running // within SquirrelSQL which uses an older incompatible version of commons-collections. // Seeing as this only results in disabling tracing, we swallow this exception and just // continue on without tracing. LOG.warn("Class incompatibility while initializing metrics, metrics will be disabled", e); } initialized = true; }
/** * Add the phoenix span receiver so we can log the traces. We have a single trace source for the * whole JVM */ public synchronized static void addTraceMetricsSource() { try { QueryServicesOptions options = QueryServicesOptions.withDefaults(); if (!initialized && options.isTracingEnabled()) { traceSpanReceiver = new TraceSpanReceiver(); Trace.addReceiver(traceSpanReceiver); TraceWriter traceWriter = new TraceWriter(options.getTableName(), options.getTracingThreadPoolSize(), options.getTracingBatchSize()); traceWriter.start(); } } catch (RuntimeException e) { LOG.warn("Tracing will outputs will not be written to any metrics sink! No " + "TraceMetricsSink found on the classpath", e); } catch (IllegalAccessError e) { // This is an issue when we have a class incompatibility error, such as when running // within SquirrelSQL which uses an older incompatible version of commons-collections. // Seeing as this only results in disabling tracing, we swallow this exception and just // continue on without tracing. LOG.warn("Class incompatibility while initializing metrics, metrics will be disabled", e); } initialized = true; }