public static String getSpanName(Span span) { return Tracing.TRACE_METRIC_PREFIX + span.getTraceId() + SEPARATOR + span.getParentId() + SEPARATOR + span.getSpanId(); }
values.add(span.getParentId());
@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(); } }
@Override public long parentId() { return span.getParentId(); }
/** * @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 int compare(Span a, Span b) { if (a.getParentId() < b.getParentId()) { return -1; } else if (a.getParentId() > b.getParentId()) { return 1; } else if (a.getSpanId() < b.getSpanId()) { return -1; } else if (a.getSpanId() > b.getSpanId()) { return 1; } else { return 0; } } };
public List<Span> find(long parentId) { List<Span> spans = new ArrayList<Span>(); Span span = new MilliSpan("", Long.MIN_VALUE, parentId, Long.MIN_VALUE, ""); while (true) { span = treeSet.higher(span); if (span == null) { break; } if (span.getParentId() != parentId) { break; } spans.add(span); } return spans; }
public static String getSpanName(Span span) { return Tracing.TRACE_METRIC_PREFIX + span.getTraceId() + SEPARATOR + span.getParentId() + SEPARATOR + span.getSpanId(); }
public static String getSpanName(Span span) { return Tracing.TRACE_METRIC_PREFIX + span.getTraceId() + SEPARATOR + span.getParentId() + SEPARATOR + span.getSpanId(); }
values.add(span.getParentId());
values.add(span.getParentId());
@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 " + maxQueueSize + " spans queued for delivery.\n" + "This does not affect performance, security or data integrity," + " but distributed tracing information is being lost."); 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(); } }
jgen.writeStringField("r", span.getProcessId()); jgen.writeArrayFieldStart("p"); if (span.getParentId() != ROOT_SPAN_ID) { jgen.writeString(String.format("%016x", span.getParentId()));