Refine search
@Override public void receiveSpan(Span s) { if (s.getStopTimeMillis() - s.getStartTimeMillis() < minSpanSize) { return; } Map<String,String> data = convertToStrings(s.getKVAnnotations()); SpanKey dest = getSpanKey(data); if (dest != null) { List<Annotation> annotations = convertToAnnotations(s.getTimelineAnnotations()); if (sendQueueSize.get() > maxQueueSize) { long now = System.currentTimeMillis(); if (now - lastNotificationOfDroppedSpans > 60 * 1000) { log.warn("Tracing spans are being dropped because there are already" + " {} spans queued for delivery.\n" + "This does not affect performance, security or data integrity," + " but distributed tracing information is being lost.", maxQueueSize); lastNotificationOfDroppedSpans = now; } return; } sendQueue.add(new RemoteSpan(host, service == null ? s.getProcessId() : service, s.getTraceId(), s.getSpanId(), s.getParentId(), s.getStartTimeMillis(), s.getStopTimeMillis(), s.getDescription(), data, annotations)); sendQueueSize.incrementAndGet(); } }
if (Trace.isTracing()) { traceScope = Trace.startSpan("LockManager.getRowLock"); traceScope.getSpan().addTimelineAnnotation("Getting a lock"); traceScope.getSpan().addTimelineAnnotation("Failed to get row lock"); iie.initCause(ie); if (traceScope != null) { traceScope.getSpan().addTimelineAnnotation("Interrupted exception getting row lock");
/** * 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)); }
public static String getSpanName(Span span) { return Tracing.TRACE_METRIC_PREFIX + span.getTraceId() + SEPARATOR + span.getParentId() + SEPARATOR + span.getSpanId(); }
@Override public void receiveSpan(Span span) { if (span.getTraceId() != 0 && spanQueue.offer(span)) { if (LOG.isTraceEnabled()) { LOG.trace("Span buffered to queue " + span.toJson()); } } else if (span.getTraceId() != 0 && LOG.isDebugEnabled()) { LOG.debug("Span NOT buffered due to overflow in queue " + span.toJson()); } }
/** * 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; } }
@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); }
@Override public void postBatchMutateIndispensably(ObserverContext<RegionCoprocessorEnvironment> c, MiniBatchOperationInProgress<Mutation> miniBatchOp, final boolean success) throws IOException { BatchMutateContext context = getBatchMutateContext(c); if (context == null || context.indexUpdates == null) { return; } // get the current span, or just use a null-span to avoid a bunch of if statements try (TraceScope scope = Trace.startSpan("Starting to write index updates")) { Span current = scope.getSpan(); if (current == null) { current = NullSpan.INSTANCE; } if (success) { // if miniBatchOp was successfully written, write index updates if (!context.indexUpdates.isEmpty()) { this.writer.write(context.indexUpdates, false, context.clientVersion); } current.addTimelineAnnotation("Wrote index updates"); } } catch (Throwable t) { String msg = "Failed to write index updates:" + context.indexUpdates; LOG.error(msg, t); ServerUtil.throwIOException(msg, t); } finally { removeBatchMutateContext(c); } }
public void writeWithTracing() throws Exception { long startTime = System.currentTimeMillis(); TraceScope ts = Trace.startSpan("testWriteTraceHooks", Sampler.ALWAYS); writeTestFile("testWriteTraceHooks.dat"); long endTime = System.currentTimeMillis(); ts.close(); Span s = map.get("testWriteTraceHooks").get(0); Assert.assertNotNull(s); long spanStart = s.getStartTimeMillis(); long spanEnd = s.getStopTimeMillis(); for (String desc : spansInTopTrace) { for (Span span : map.get(desc)) { Assert.assertEquals(ts.getSpan().getTraceId(), span.getTraceId());
TraceScope getPathTraceScope(String description, String path) { TraceScope scope = Trace.startSpan(description, traceSampler); Span span = scope.getSpan(); if (span != null) { if (path != null) { span.addKVAnnotation(PATH, path.getBytes(Charset.forName("UTF-8"))); } } return scope; }
rowRangeIterator.next(); TraceScope scope = org.apache.htrace.Trace.startSpan("RWI seek"); if (Trace.isTracing()) scope.getSpan().addKVAnnotation(SEEK_RANGE, range.toString().getBytes(StandardCharsets.UTF_8)); try { writeWrapper(true/*, initialSeek*/); } finally { scope.close();
assertTrue(rs.next()); PhoenixConnection pconn = (PhoenixConnection) conn1; long traceId = pconn.getTraceScope().getSpan().getTraceId(); assertEquals(traceId, rs.getLong(1)); assertEquals(traceId, rs.getLong("trace_id")); traceId = pconn.getTraceScope().getSpan() .getTraceId(); assertEquals(traceId, rs.getLong(1)); assertEquals(traceId, rs.getLong("trace_id"));
/** * @param spans * @param trace */ private void validateTrace(List<Span> spans, TraceHolder trace) { // drop each span into a sorted list so we get the expected ordering Iterator<SpanInfo> spanIter = trace.spans.iterator(); for (Span span : spans) { SpanInfo spanInfo = spanIter.next(); LOG.info("Checking span:\n" + spanInfo); long parentId = span.getParentId(); if(parentId == Span.ROOT_SPAN_ID) { assertNull("Got a parent, but it was a root span!", spanInfo.parent); } else { assertEquals("Got an unexpected parent span id", parentId, spanInfo.parent.id); } assertEquals("Got an unexpected start time", span.getStartTimeMillis(), spanInfo.start); assertEquals("Got an unexpected end time", span.getStopTimeMillis(), spanInfo.end); int annotationCount = 0; for(Map.Entry<byte[], byte[]> entry : span.getKVAnnotations().entrySet()) { int count = annotationCount++; assertEquals("Didn't get expected annotation", count + " - " + Bytes.toString(entry.getValue()), spanInfo.annotations.get(count)); } assertEquals("Didn't get expected number of annotations", annotationCount, spanInfo.annotationCount); } }
@Override public Tuple next() throws SQLException { if (!started) { scope.getSpan().addTimelineAnnotation("First request completed"); started = true; } return super.next(); }
Span span = trace.getSpan(); ImmutableBytesWritable indexMetaDataPtr = new ImmutableBytesWritable(); while (tableRefIterator.hasNext()) { child.addTimelineAnnotation("Attempt " + retryCount); List<List<Mutation>> mutationBatchList = getMutationBatchList(batchSize, batchSizeBytes, mutationList); + Bytes.toString(htableName)); child.stop(); child.stop(); shouldRetry = false; mutationCommitTime = System.currentTimeMillis() - startTime; child.addTimelineAnnotation(msg); child.stop(); child = Tracing.child(span, "Failed batch, attempting retry");
/** * Annotate the current span with the given message. */ public static void addTimelineAnnotation(String msg) { Span s = currentSpan(); if (s != null) { s.addTimelineAnnotation(msg); } }
/** * Starts and returns a new span as the child of the parameter 'parent'. This * will always return a new span, even if tracing wasn't previously enabled for * this thread. * * @param description Description of the span to be created. * @param parent The parent that should be used to create the child span that is to * be returned. * @return */ public static TraceScope startSpan(String description, Span parent) { if (parent == null) return startSpan(description); return continueSpan(parent.child(description)); }
MemStoreScanner(long readPoint) { super(); this.readPoint = readPoint; cellSetAtCreation = cellSet; snapshotAtCreation = snapshot; if (allocator != null) { this.allocatorAtCreation = allocator; this.allocatorAtCreation.incScannerCount(); } if (snapshotAllocator != null) { this.snapshotAllocatorAtCreation = snapshotAllocator; this.snapshotAllocatorAtCreation.incScannerCount(); } if (Trace.isTracing() && Trace.currentSpan() != null) { Trace.currentSpan().addTimelineAnnotation("Creating MemStoreScanner"); } }
/** * Get the trace id of the current span. */ public static long currentTraceId() { return org.apache.htrace.Trace.currentSpan().getTraceId(); }