class Receiver implements Iface {
@Override
public void span(RemoteSpan s) throws TException {
String idString = Long.toHexString(s.traceId);
String startString = Long.toHexString(s.start);
Mutation spanMutation = new Mutation(new Text(idString));
Mutation indexMutation = new Mutation(new Text("idx:" + s.svc + ":" + startString));
long diff = s.stop - s.start;
indexMutation.put(new Text(s.description), new Text(s.sender), new Value((idString + ":" + Long.toHexString(diff)).getBytes(Constants.UTF8)));
ByteArrayTransport transport = new ByteArrayTransport();
TCompactProtocol protocol = new TCompactProtocol(transport);
s.write(protocol);
String parentString = Long.toHexString(s.parentId);
if (s.parentId == Span.ROOT_SPAN_ID)
parentString = "";
put(spanMutation, "span", parentString + ":" + Long.toHexString(s.spanId), transport.get(), transport.len());
// Map the root span to time so we can look up traces by time
Mutation timeMutation = null;
if (s.parentId == Span.ROOT_SPAN_ID) {
timeMutation = new Mutation(new Text("start:" + startString));
put(timeMutation, "id", idString, transport.get(), transport.len());
}
try {
final BatchWriter writer = TraceServer.this.writer.get();
/* Check for null, because we expect spans to come in much faster than flush calls.