/** * Add data to the current span. */ public static void data(String k, String v) { org.apache.htrace.Span span = org.apache.htrace.Trace.currentSpan(); if (span != null) span.addKVAnnotation(k.getBytes(UTF_8), v.getBytes(UTF_8)); }
/** * Get the trace id of the current span. */ public static long currentTraceId() { return org.apache.htrace.Trace.currentSpan().getTraceId(); }
/** * Wrap a runnable in a TraceRunnable, if tracing. */ public static Runnable wrap(Runnable runnable) { if (isTracing()) { return new TraceRunnable(org.apache.htrace.Trace.currentSpan(), runnable); } else { return runnable; } }
/** * Wrap the callable in a TraceCallable, if tracing. * @param callable to call * @param description description of the operation being run. If <tt>null</tt> uses the current * thread name * @return The callable provided, wrapped if tracing, 'callable' if not. */ public static <V> Callable<V> wrap(Callable<V> callable, String description) { if (Trace.isTracing()) { return new TraceCallable<V>(Trace.currentSpan(), callable, description); } return callable; }
/** * Obtain {@link org.apache.accumulo.core.trace.thrift.TInfo} for the current span. */ public static TInfo traceInfo() { Span span = org.apache.htrace.Trace.currentSpan(); if (span != null) { return new TInfo(span.getTraceId(), span.getSpanId()); } return DONT_TRACE; } }
/** * Finish the current trace. */ public static void off() { org.apache.htrace.Span span = org.apache.htrace.Trace.currentSpan(); if (span != null) { span.stop(); // close() will no-op, but ensure safety if the implementation changes org.apache.htrace.Tracer.getInstance().continueSpan(null).close(); } }
final Span savedSpan = Trace.currentSpan(); final Span child = Trace.startSpan(SCANNER_OPENED_TRACE_INFO, savedSpan).getSpan(); try {
/** * Return the current span. * * @deprecated since 1.7 -- it is better to save the span you create in a local variable and call * its methods, rather than retrieving the current span */ @Deprecated public static Span currentTrace() { return new Span(org.apache.htrace.Trace.currentSpan()); }
/** * Adds a data annotation to the current span if tracing is currently on. */ public static void addKVAnnotation(byte[] key, byte[] value) { Span s = currentSpan(); if (s != null) { s.addKVAnnotation(key, value); } }
/** * Annotate the current span with the given message. */ public static void addTimelineAnnotation(String msg) { Span s = currentSpan(); if (s != null) { s.addTimelineAnnotation(msg); } }
/** * Add data to the current span. */ public static void data(String k, String v) { org.apache.htrace.Span span = org.apache.htrace.Trace.currentSpan(); if (span != null) span.addKVAnnotation(k.getBytes(UTF_8), v.getBytes(UTF_8)); }
/** * Get the trace id of the current span. */ public static long currentTraceId() { return org.apache.htrace.Trace.currentSpan().getTraceId(); }
private void queueCurrentPacket() { synchronized (dataQueue) { if (currentPacket == null) return; currentPacket.addTraceParent(Trace.currentSpan()); dataQueue.addLast(currentPacket); lastQueuedSeqno = currentPacket.getSeqno(); if (DFSClient.LOG.isDebugEnabled()) { DFSClient.LOG.debug("Queued packet " + currentPacket.getSeqno()); } currentPacket = null; dataQueue.notifyAll(); } }
/** * Wrap a runnable in a TraceRunnable, if tracing. */ public static Runnable wrap(Runnable runnable) { if (isTracing()) { return new TraceRunnable(org.apache.htrace.Trace.currentSpan(), runnable); } else { return runnable; } }
/** * Wrap the callable in a TraceCallable, if tracing. * @param callable to call * @param description description of the operation being run. If <tt>null</tt> uses the current * thread name * @return The callable provided, wrapped if tracing, 'callable' if not. */ public static <V> Callable<V> wrap(Callable<V> callable, String description) { if (Trace.isTracing()) { return new TraceCallable<V>(Trace.currentSpan(), callable, description); } return callable; }
/** * Wrap the callable in a TraceCallable, if tracing. * * @param callable * @return The callable provided, wrapped if tracing, 'callable' if not. */ public static <V> Callable<V> wrap(Callable<V> callable) { if (isTracing()) { return new TraceCallable<V>(Trace.currentSpan(), callable); } else { return callable; } }
/** * Obtain {@link org.apache.accumulo.core.trace.thrift.TInfo} for the current span. */ public static TInfo traceInfo() { Span span = org.apache.htrace.Trace.currentSpan(); if (span != null) { return new TInfo(span.getTraceId(), span.getSpanId()); } return DONT_TRACE; } }
/** * Finish the current trace. */ public static void off() { org.apache.htrace.Span span = org.apache.htrace.Trace.currentSpan(); if (span != null) { span.stop(); // close() will no-op, but ensure safety if the implementation changes org.apache.htrace.Tracer.getInstance().continueSpan(null).close(); } }
static BaseHeaderProto buildBaseHeader(ExtendedBlock blk, Token<BlockTokenIdentifier> blockToken) { BaseHeaderProto.Builder builder = BaseHeaderProto.newBuilder() .setBlock(PBHelper.convert(blk)) .setToken(PBHelper.convert(blockToken)); if (Trace.isTracing()) { Span s = Trace.currentSpan(); builder.setTraceInfo(DataTransferTraceInfoProto.newBuilder() .setTraceId(s.getTraceId()) .setParentId(s.getSpanId())); } return builder.build(); }
static BaseHeaderProto buildBaseHeader(ExtendedBlock blk, Token<BlockTokenIdentifier> blockToken) { BaseHeaderProto.Builder builder = BaseHeaderProto.newBuilder() .setBlock(PBHelper.convert(blk)) .setToken(PBHelper.convert(blockToken)); if (Trace.isTracing()) { Span s = Trace.currentSpan(); builder.setTraceInfo(DataTransferTraceInfoProto.newBuilder() .setTraceId(s.getTraceId()) .setParentId(s.getSpanId())); } return builder.build(); }