/** * Wrapper method to add timeline annotiation to current span with given message */ public static void addTimelineAnnotation(String msg) { Span span = Tracer.getCurrentSpan(); if (span != null) { span.addTimelineAnnotation(msg); } }
/** * Wrapper method to remove receiver from actual tracerpool * @return true if removed, false if doesn't exist */ public static boolean removeReceiver(SpanReceiver rcvr) { return (tracer == null) ? false : tracer.getTracerPool().removeReceiver(rcvr); }
/** * Wrapper method to add key-value pair to TraceInfo of actual span */ public static void addKVAnnotation(String key, String value){ Span span = Tracer.getCurrentSpan(); if (span != null) { span.addKVAnnotation(key, value); } }
public static void initTracer(Configuration c) { if(c != null) { conf = new HBaseHTraceConfiguration(c); } if (tracer == null && conf != null) { tracer = new Tracer.Builder("Tracer").conf(conf).build(); } }
/** * Wrapper method to create new child TraceScope with the given description * and parent scope's spanId * @param span parent span * @return TraceScope or null when not tracing */ public static TraceScope createTrace(String description, Span span) { if(span == null) return createTrace(description); return (tracer == null) ? null : tracer.newScope(description, span.getSpanId()); }
public FileStatus[] glob() throws IOException { TraceScope scope = tracer.newScope("Globber#glob"); scope.addKVAnnotation("pattern", pathPattern.toUri().getPath()); try { return doGlob(); } finally { scope.close(); } }
/** * Wrapper method to create new TraceScope with the given description * @return TraceScope or null when not tracing */ public static TraceScope createTrace(String description) { return (tracer == null) ? null : tracer.newScope(description); }
/** * Default base class constructor. */ public EventHandler(Server server, EventType eventType) { this.parent = Tracer.getCurrentSpan(); this.server = server; this.eventType = eventType; seqid = seqids.incrementAndGet(); if (server != null) { this.waitingTimeForEvents = server.getConfiguration(). getInt("hbase.master.event.waiting.time", 1000); } }
/** * Wrapper method to add receiver to actual tracerpool * @return true if successfull, false if it was already added */ public static boolean addReceiver(SpanReceiver rcvr) { return (tracer == null) ? false : tracer.getTracerPool().addReceiver(rcvr); }
public synchronized void removeSpanReceiver(long spanReceiverId) throws IOException { SpanReceiver[] receivers = TracerPool.getGlobalTracerPool().getReceivers(); for (SpanReceiver receiver : receivers) { if (receiver.getId() == spanReceiverId) { TracerPool.getGlobalTracerPool().removeAndCloseReceiver(receiver); LOG.info("Successfully removed SpanReceiver " + spanReceiverId + " with class " + receiver.getClass().getName()); return; } } throw new IOException("There is no span receiver with id " + spanReceiverId); } }
/** * Wrap runnable with current tracer and description * @param runnable to wrap * @return wrapped runnable or original runnable when not tracing */ public static Runnable wrap(Runnable runnable, String description) { return (tracer == null) ? runnable : tracer.wrap(runnable, description); } }
public synchronized SpanReceiverInfo[] listSpanReceivers() throws IOException { TracerPool pool = TracerPool.getGlobalTracerPool(); SpanReceiver[] receivers = pool.getReceivers(); SpanReceiverInfo[] info = new SpanReceiverInfo[receivers.length]; for (int i = 0; i < receivers.length; i++) { SpanReceiver receiver = receivers[i]; info[i] = new SpanReceiverInfo(receiver.getId(), receiver.getClass().getName()); } return info; }
@VisibleForTesting public static synchronized void clear() { if (instance == null) { return; } try { instance.close(); } finally { instance = null; } }
/** * Calls close() on all SpanReceivers created by this SpanReceiverHost. */ public synchronized void closeReceivers() { if (closed) return; closed = true; for (SpanReceiver rcvr : receivers) { try { rcvr.close(); } catch (IOException e) { LOG.warn("Unable to close SpanReceiver correctly: " + e.getMessage(), e); } } } }
/** * Wrapper method to add new sampler to the default tracer * @return true if added, false if it was already added */ public static boolean addSampler(Sampler sampler) { if (sampler == null) { return false; } return (tracer == null) ? false : tracer.addSampler(sampler); }
@Override public String toString() { StringBuilder bld = new StringBuilder(); String prefix = ""; for (Iterator<Span> iter = spansByParent.iterator(); iter.hasNext();) { Span span = iter.next(); bld.append(prefix).append(span.toString()); prefix = "\n"; } return bld.toString(); } }
public static synchronized Tracer get(Configuration conf) { if (instance == null) { instance = new Tracer.Builder("FSClient"). conf(TraceUtils.wrapHadoopConf(CommonConfigurationKeys. FS_CLIENT_HTRACE_PREFIX, conf)). build(); } return instance; }
protected Call(int id, final Descriptors.MethodDescriptor md, Message param, final CellScanner cells, final Message responseDefaultType, int timeout, int priority, RpcCallback<Call> callback, MetricsConnection.CallStats callStats) { this.param = param; this.md = md; this.cells = cells; this.callStats = callStats; this.callStats.setStartTime(EnvironmentEdgeManager.currentTime()); this.responseDefaultType = responseDefaultType; this.id = id; this.timeout = timeout; this.priority = priority; this.callback = callback; this.span = Tracer.getCurrentSpan(); }