use of org.apache.htrace.core.SpanId in project hadoop by apache.
the class DataTransferProtoUtil method buildBaseHeader.
static BaseHeaderProto buildBaseHeader(ExtendedBlock blk, Token<BlockTokenIdentifier> blockToken) {
BaseHeaderProto.Builder builder = BaseHeaderProto.newBuilder().setBlock(PBHelperClient.convert(blk)).setToken(PBHelperClient.convert(blockToken));
SpanId spanId = Tracer.getCurrentSpanId();
if (spanId.isValid()) {
builder.setTraceInfo(DataTransferTraceInfoProto.newBuilder().setTraceId(spanId.getHigh()).setParentId(spanId.getLow()));
}
return builder.build();
}
use of org.apache.htrace.core.SpanId in project hadoop by apache.
the class DFSPacket method getTraceParents.
/**
* Get the trace parent spans for this packet.<p/>
*
* Will always be non-null.<p/>
*
* Protected by the DFSOutputStream dataQueue lock.
*/
public SpanId[] getTraceParents() {
// Remove duplicates from the array.
int len = traceParentsUsed;
Arrays.sort(traceParents, 0, len);
int i = 0, j = 0;
SpanId prevVal = SpanId.INVALID;
while (true) {
if (i == len) {
break;
}
SpanId val = traceParents[i];
if (!val.equals(prevVal)) {
traceParents[j] = val;
j++;
prevVal = val;
}
i++;
}
if (j < traceParents.length) {
traceParents = Arrays.copyOf(traceParents, j);
traceParentsUsed = traceParents.length;
}
return traceParents;
}
use of org.apache.htrace.core.SpanId in project cxf by apache.
the class HTraceTracingTest method testThatNewInnerSpanIsCreatedUsingAsyncInvocation.
@Test
public void testThatNewInnerSpanIsCreatedUsingAsyncInvocation() {
final SpanId spanId = SpanId.fromRandom();
final Response r = createWebClient("/bookstore/books/async").header(TracerHeaders.DEFAULT_HEADER_SPAN_ID, spanId.toString()).get();
assertEquals(Status.OK.getStatusCode(), r.getStatus());
assertThat(TestSpanReceiver.getAllSpans().size(), equalTo(2));
assertThat(TestSpanReceiver.getAllSpans().get(1).getDescription(), equalTo("GET bookstore/books/async"));
assertThat(TestSpanReceiver.getAllSpans().get(0).getDescription(), equalTo("Processing books"));
assertThat((String) r.getHeaders().getFirst(TracerHeaders.DEFAULT_HEADER_SPAN_ID), equalTo(spanId.toString()));
}
use of org.apache.htrace.core.SpanId in project cxf by apache.
the class HTraceTracingTest method testThatParallelSpanIsAnnotatedWithTimeline.
@Test
public void testThatParallelSpanIsAnnotatedWithTimeline() {
final SpanId spanId = SpanId.fromRandom();
final Response r = createWebClient("/bookstore/process").header(TracerHeaders.DEFAULT_HEADER_SPAN_ID, spanId.toString()).put("");
assertEquals(Status.OK.getStatusCode(), r.getStatus());
assertThat(TestSpanReceiver.getAllSpans().size(), equalTo(2));
assertThat(TestSpanReceiver.getAllSpans(), hasSpan("Processing books", hasItem("Processing started")));
assertThat(TestSpanReceiver.getAllSpans(), hasSpan("PUT bookstore/process", empty()));
assertThat((String) r.getHeaders().getFirst(TracerHeaders.DEFAULT_HEADER_SPAN_ID), equalTo(spanId.toString()));
}
use of org.apache.htrace.core.SpanId in project cxf by apache.
the class HTraceTracingTest method testThatInnerSpanIsCreatedUsingPseudoAsyncInvocation.
@Test
public void testThatInnerSpanIsCreatedUsingPseudoAsyncInvocation() {
final SpanId spanId = SpanId.fromRandom();
final Response r = createWebClient("/bookstore/books/pseudo-async").header(TracerHeaders.DEFAULT_HEADER_SPAN_ID, spanId.toString()).get();
assertEquals(Status.OK.getStatusCode(), r.getStatus());
assertThat(TestSpanReceiver.getAllSpans().size(), equalTo(2));
assertThat(TestSpanReceiver.getAllSpans().get(1).getDescription(), equalTo("GET bookstore/books/pseudo-async"));
assertThat(TestSpanReceiver.getAllSpans().get(0).getDescription(), equalTo("Processing books"));
assertThat((String) r.getHeaders().getFirst(TracerHeaders.DEFAULT_HEADER_SPAN_ID), equalTo(spanId.toString()));
}
Aggregations