Java Code Examples for org.apache.htrace.Span#ROOT_SPAN_ID

The following examples show how to use org.apache.htrace.Span#ROOT_SPAN_ID . 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: TraceReader.java    From phoenix with Apache License 2.0 6 votes vote down vote up
/**
 * Do the same sorting that we would get from reading the table with a {@link TraceReader},
 * specifically, by trace and then by start/end. However, these are only every stored in a
 * single trace, so we can just sort on start/end times.
 */
@Override
public int compareTo(SpanInfo o) {
    // root span always comes first
    if (this.parentId == Span.ROOT_SPAN_ID) {
        return -1;
    } else if (o.parentId == Span.ROOT_SPAN_ID) {
        return 1;
    }

    int compare = Longs.compare(start, o.start);
    if (compare == 0) {
        compare = Longs.compare(end, o.end);
        if (compare == 0) {
            return Longs.compare(id, o.id);
        }
    }
    return compare;
}
 
Example 2
Source File: TraceReader.java    From phoenix with Apache License 2.0 6 votes vote down vote up
/**
 * Do the same sorting that we would get from reading the table with a {@link TraceReader},
 * specifically, by trace and then by start/end. However, these are only every stored in a
 * single trace, so we can just sort on start/end times.
 */
@Override
public int compareTo(SpanInfo o) {
    // root span always comes first
    if (this.parentId == Span.ROOT_SPAN_ID) {
        return -1;
    } else if (o.parentId == Span.ROOT_SPAN_ID) {
        return 1;
    }

    int compare = Longs.compare(start, o.start);
    if (compare == 0) {
        compare = Longs.compare(end, o.end);
        if (compare == 0) {
            return Longs.compare(id, o.id);
        }
    }
    return compare;
}
 
Example 3
Source File: PhoenixTraceReaderIT.java    From phoenix with Apache License 2.0 5 votes vote down vote up
/**
 * @param records
 * @param trace
 */
private void validateTrace(List<MetricsRecord> records, TraceHolder trace) {
    // drop each span into a sorted list so we get the expected ordering
    Iterator<SpanInfo> spanIter = trace.spans.iterator();
    for (MetricsRecord record : records) {
        SpanInfo spanInfo = spanIter.next();
        LOG.info("Checking span:\n" + spanInfo);
        Iterator<AbstractMetric> metricIter = record.metrics().iterator();
        assertEquals("Got an unexpected span id", metricIter.next().value(), spanInfo.id);
        long parentId = (Long) metricIter.next().value();
        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", metricIter.next().value(), spanInfo.start);
        assertEquals("Got an unexpected end time", metricIter.next().value(), spanInfo.end);

        Iterator<MetricsTag> tags = record.tags().iterator();

        int annotationCount = 0;
        while (tags.hasNext()) {
            // hostname is a tag, so we differentiate it
            MetricsTag tag = tags.next();
            if (tag.name().equals(MetricInfo.HOSTNAME.traceName)) {
                assertEquals("Didn't store correct hostname value", tag.value(),
                    spanInfo.hostname);
            } else {
                int count = annotationCount++;
                assertEquals("Didn't get expected annotation", count + " - " + tag.value(),
                    spanInfo.annotations.get(count));
            }
        }
        assertEquals("Didn't get expected number of annotations", annotationCount,
            spanInfo.annotationCount);
    }
}