Java Code Examples for org.apache.htrace.Trace#currentSpan()
The following examples show how to use
org.apache.htrace.Trace#currentSpan() .
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: DFSInputStream.java From hadoop with Apache License 2.0 | 6 votes |
private Callable<ByteBuffer> getFromOneDataNode(final DNAddrPair datanode, final LocatedBlock block, final long start, final long end, final ByteBuffer bb, final Map<ExtendedBlock, Set<DatanodeInfo>> corruptedBlockMap, final int hedgedReadId) { final Span parentSpan = Trace.currentSpan(); return new Callable<ByteBuffer>() { @Override public ByteBuffer call() throws Exception { byte[] buf = bb.array(); int offset = bb.position(); TraceScope scope = Trace.startSpan("hedgedRead" + hedgedReadId, parentSpan); try { actualGetFromOneDataNode(datanode, block, start, end, buf, offset, corruptedBlockMap); return bb; } finally { scope.close(); } } }; }
Example 2
Source File: ProtoUtil.java From hadoop with Apache License 2.0 | 6 votes |
public static RpcRequestHeaderProto makeRpcRequestHeader(RPC.RpcKind rpcKind, RpcRequestHeaderProto.OperationProto operation, int callId, int retryCount, byte[] uuid) { RpcRequestHeaderProto.Builder result = RpcRequestHeaderProto.newBuilder(); result.setRpcKind(convert(rpcKind)).setRpcOp(operation).setCallId(callId) .setRetryCount(retryCount).setClientId(ByteString.copyFrom(uuid)); // Add tracing info if we are currently tracing. if (Trace.isTracing()) { Span s = Trace.currentSpan(); result.setTraceInfo(RPCTraceInfoProto.newBuilder() .setParentId(s.getSpanId()) .setTraceId(s.getTraceId()).build()); } return result.build(); }
Example 3
Source File: DFSInputStream.java From big-c with Apache License 2.0 | 6 votes |
private Callable<ByteBuffer> getFromOneDataNode(final DNAddrPair datanode, final LocatedBlock block, final long start, final long end, final ByteBuffer bb, final Map<ExtendedBlock, Set<DatanodeInfo>> corruptedBlockMap, final int hedgedReadId) { final Span parentSpan = Trace.currentSpan(); return new Callable<ByteBuffer>() { @Override public ByteBuffer call() throws Exception { byte[] buf = bb.array(); int offset = bb.position(); TraceScope scope = Trace.startSpan("hedgedRead" + hedgedReadId, parentSpan); try { actualGetFromOneDataNode(datanode, block, start, end, buf, offset, corruptedBlockMap); return bb; } finally { scope.close(); } } }; }
Example 4
Source File: ProtoUtil.java From big-c with Apache License 2.0 | 6 votes |
public static RpcRequestHeaderProto makeRpcRequestHeader(RPC.RpcKind rpcKind, RpcRequestHeaderProto.OperationProto operation, int callId, int retryCount, byte[] uuid) { RpcRequestHeaderProto.Builder result = RpcRequestHeaderProto.newBuilder(); result.setRpcKind(convert(rpcKind)).setRpcOp(operation).setCallId(callId) .setRetryCount(retryCount).setClientId(ByteString.copyFrom(uuid)); // Add tracing info if we are currently tracing. if (Trace.isTracing()) { Span s = Trace.currentSpan(); result.setTraceInfo(RPCTraceInfoProto.newBuilder() .setParentId(s.getSpanId()) .setTraceId(s.getTraceId()).build()); } return result.build(); }
Example 5
Source File: Sender.java From hadoop with Apache License 2.0 | 5 votes |
@Override public void releaseShortCircuitFds(SlotId slotId) throws IOException { ReleaseShortCircuitAccessRequestProto.Builder builder = ReleaseShortCircuitAccessRequestProto.newBuilder(). setSlotId(PBHelper.convert(slotId)); if (Trace.isTracing()) { Span s = Trace.currentSpan(); builder.setTraceInfo(DataTransferTraceInfoProto.newBuilder() .setTraceId(s.getTraceId()).setParentId(s.getSpanId())); } ReleaseShortCircuitAccessRequestProto proto = builder.build(); send(out, Op.RELEASE_SHORT_CIRCUIT_FDS, proto); }
Example 6
Source File: Sender.java From hadoop with Apache License 2.0 | 5 votes |
@Override public void requestShortCircuitShm(String clientName) throws IOException { ShortCircuitShmRequestProto.Builder builder = ShortCircuitShmRequestProto.newBuilder(). setClientName(clientName); if (Trace.isTracing()) { Span s = Trace.currentSpan(); builder.setTraceInfo(DataTransferTraceInfoProto.newBuilder() .setTraceId(s.getTraceId()).setParentId(s.getSpanId())); } ShortCircuitShmRequestProto proto = builder.build(); send(out, Op.REQUEST_SHORT_CIRCUIT_SHM, proto); }
Example 7
Source File: DataTransferProtoUtil.java From hadoop with Apache License 2.0 | 5 votes |
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(); }
Example 8
Source File: Sender.java From big-c with Apache License 2.0 | 5 votes |
@Override public void releaseShortCircuitFds(SlotId slotId) throws IOException { ReleaseShortCircuitAccessRequestProto.Builder builder = ReleaseShortCircuitAccessRequestProto.newBuilder(). setSlotId(PBHelper.convert(slotId)); if (Trace.isTracing()) { Span s = Trace.currentSpan(); builder.setTraceInfo(DataTransferTraceInfoProto.newBuilder() .setTraceId(s.getTraceId()).setParentId(s.getSpanId())); } ReleaseShortCircuitAccessRequestProto proto = builder.build(); send(out, Op.RELEASE_SHORT_CIRCUIT_FDS, proto); }
Example 9
Source File: Sender.java From big-c with Apache License 2.0 | 5 votes |
@Override public void requestShortCircuitShm(String clientName) throws IOException { ShortCircuitShmRequestProto.Builder builder = ShortCircuitShmRequestProto.newBuilder(). setClientName(clientName); if (Trace.isTracing()) { Span s = Trace.currentSpan(); builder.setTraceInfo(DataTransferTraceInfoProto.newBuilder() .setTraceId(s.getTraceId()).setParentId(s.getSpanId())); } ShortCircuitShmRequestProto proto = builder.build(); send(out, Op.REQUEST_SHORT_CIRCUIT_SHM, proto); }
Example 10
Source File: DataTransferProtoUtil.java From big-c with Apache License 2.0 | 5 votes |
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(); }
Example 11
Source File: BaseScannerRegionObserver.java From phoenix with Apache License 2.0 | 4 votes |
/** * Wrapper for {@link #postScannerOpen(ObserverContext, Scan, RegionScanner)} that ensures no non IOException is thrown, * to prevent the coprocessor from becoming blacklisted. * */ @Override public final RegionScanner postScannerOpen( final ObserverContext<RegionCoprocessorEnvironment> c, final Scan scan, final RegionScanner s) throws IOException { try { if (!isRegionObserverFor(scan)) { return s; } boolean success =false; // Save the current span. When done with the child span, reset the span back to // what it was. Otherwise, this causes the thread local storing the current span // to not be reset back to null causing catastrophic infinite loops // and region servers to crash. See https://issues.apache.org/jira/browse/PHOENIX-1596 // TraceScope can't be used here because closing the scope will end up calling // currentSpan.stop() and that should happen only when we are closing the scanner. final Span savedSpan = Trace.currentSpan(); final Span child = Trace.startSpan(SCANNER_OPENED_TRACE_INFO, savedSpan).getSpan(); try { RegionScanner scanner = doPostScannerOpen(c, scan, s); scanner = new DelegateRegionScanner(scanner) { // This isn't very obvious but close() could be called in a thread // that is different from the thread that created the scanner. @Override public void close() throws IOException { try { delegate.close(); } finally { if (child != null) { child.stop(); } } } }; success = true; return scanner; } finally { try { if (!success && child != null) { child.stop(); } } finally { Trace.continueSpan(savedSpan); } } } catch (Throwable t) { ServerUtil.throwIOException(c.getEnvironment().getRegion().getRegionNameAsString(), t); return null; // impossible } }
Example 12
Source File: BaseScannerRegionObserver.java From phoenix with Apache License 2.0 | 4 votes |
private void overrideDelegate() throws IOException { if (wasOverriden) { return; } boolean success = false; // Save the current span. When done with the child span, reset the span back to // what it was. Otherwise, this causes the thread local storing the current span // to not be reset back to null causing catastrophic infinite loops // and region servers to crash. See https://issues.apache.org/jira/browse/PHOENIX-1596 // TraceScope can't be used here because closing the scope will end up calling // currentSpan.stop() and that should happen only when we are closing the scanner. final Span savedSpan = Trace.currentSpan(); final Span child = Trace.startSpan(SCANNER_OPENED_TRACE_INFO, savedSpan).getSpan(); try { RegionScanner scanner = doPostScannerOpen(c, scan, delegate); scanner = new DelegateRegionScanner(scanner) { // This isn't very obvious but close() could be called in a thread // that is different from the thread that created the scanner. @Override public void close() throws IOException { try { delegate.close(); } finally { if (child != null) { child.stop(); } } } }; this.delegate = scanner; wasOverriden = true; success = true; } catch (Throwable t) { ServerUtil.throwIOException(c.getEnvironment().getRegionInfo().getRegionNameAsString(), t); } finally { try { if (!success && child != null) { child.stop(); } } finally { Trace.continueSpan(savedSpan); } } }
Example 13
Source File: Tracing.java From phoenix with Apache License 2.0 | 3 votes |
/** * 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; }
Example 14
Source File: Tracing.java From phoenix with Apache License 2.0 | 3 votes |
/** * 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; }