assertEquals("creating table", createTableSpan.getDescription());
@Override public void receiveSpan(Span span) { if (running.get()) { try { this.queue.add(span); } catch (IllegalStateException e) { LOG.error("Error trying to append span (" + span.getDescription() + ") to the queue. Blocking Queue was full."); } } } }
@Override public void receiveSpan(Span span) { if (running.get()) { try { this.queue.add(span); } catch (IllegalStateException e) { LOG.error("Error trying to append span (" + span.getDescription() + ") to the queue." + " Blocking Queue was full."); } } } }
@Override public void receiveSpan(Span span) { if (running.get()) { try { this.queue.add(span); } catch (IllegalStateException e) { LOG.error("Error trying to append span (" + span.getDescription() + ") to the queue." + " Blocking Queue was full."); } } } }
@Override public void receiveSpan(Span span) { if (running.get()) { try { this.queue.add(span); } catch (IllegalStateException e) { // todo: supress repeating error logs. LOG.error("Error trying to append span (" + span.getDescription() + ") to the queue. Blocking Queue was full."); } } }
@Override public String call() throws Exception { return Tracer.getCurrentSpan().getDescription(); } }).get(WAIT_TIME_SECONDS, TimeUnit.SECONDS);
@Override public void run() { description.set(Tracer.getCurrentSpan().getDescription()); } }).get(WAIT_TIME_SECONDS, TimeUnit.SECONDS);
headers.put("SpanId", span.toString()); headers.put("TracerId", span.getTracerId()); headers.put("Description", span.getDescription());
@Override public String call() throws InterruptedException { startLatch.countDown(); // Prevent any task from exiting until every task has started assertTrue(continueLatch.await(WAIT_TIME_SECONDS, TimeUnit.SECONDS)); // Annotate on the presumed child trace Tracer.getCurrentSpan().addTimelineAnnotation( Thread.currentThread().getName()); return Tracer.getCurrentSpan().getDescription(); } };
jgen.writeNumberField("e", span.getStopTimeMillis()); if (!span.getDescription().isEmpty()) { jgen.writeStringField("d", span.getDescription());
jgen.writeNumberField("e", span.getStopTimeMillis()); if (!span.getDescription().isEmpty()) { jgen.writeStringField("d", span.getDescription());
jgen.writeNumberField("e", span.getStopTimeMillis()); if (!span.getDescription().isEmpty()) { jgen.writeStringField("d", span.getDescription());
assertEquals("creating table", createTableSpan.getDescription());
descriptionToRootSpan.put(root.getDescription(), root);
private void compareSpans(Span expected, Span got) throws Exception { assertEquals(expected.getStartTimeMillis(), got.getStartTimeMillis()); assertEquals(expected.getStopTimeMillis(), got.getStopTimeMillis()); assertEquals(expected.getDescription(), got.getDescription()); assertEquals(expected.getSpanId(), got.getSpanId()); assertEquals(expected.getTracerId(), got.getTracerId());
/** * Converts a given HTrace span to a Zipkin Span. * <ul> * <li>First set the start annotation. [CS, SR], depending whether it is a client service or not. * <li>Set other id's, etc [TraceId's etc] * <li>Create binary annotations based on data from HTrace Span object. * <li>Set the last annotation. [SS, CR] * </ul> */ public Span convert(org.apache.htrace.core.Span hTraceSpan) { Span zipkinSpan = new Span(); String serviceName = hTraceSpan.getTracerId().toLowerCase(); Endpoint ep = new Endpoint(ipv4Address, (short) getPort(serviceName), serviceName); List<Annotation> annotationList = createZipkinAnnotations(hTraceSpan, ep); List<BinaryAnnotation> binaryAnnotationList = createZipkinBinaryAnnotations(hTraceSpan, ep); zipkinSpan.setTrace_id(hTraceSpan.getSpanId().getHigh()); if (hTraceSpan.getParents().length > 0) { if (hTraceSpan.getParents().length > 1) { LOG.error("zipkin doesn't support spans with multiple parents. Omitting " + "other parents for " + hTraceSpan); } zipkinSpan.setParent_id(hTraceSpan.getParents()[0].getLow()); } zipkinSpan.setId(hTraceSpan.getSpanId().getLow()); zipkinSpan.setName(hTraceSpan.getDescription()); zipkinSpan.setAnnotations(annotationList); zipkinSpan.setBinary_annotations(binaryAnnotationList); return zipkinSpan; }
/** * Converts a given HTrace span to a Zipkin Span. * <ul> * <li>First set the start annotation. [CS, SR], depending whether it is a client service or not. * <li>Set other id's, etc [TraceId's etc] * <li>Create binary annotations based on data from HTrace Span object. * <li>Set the last annotation. [SS, CR] * </ul> */ public Span convert(org.apache.htrace.core.Span hTraceSpan) { Span zipkinSpan = new Span(); String serviceName = hTraceSpan.getTracerId().toLowerCase(); Endpoint ep = new Endpoint(ipv4Address, (short) getPort(serviceName), serviceName); List<Annotation> annotationList = createZipkinAnnotations(hTraceSpan, ep); List<BinaryAnnotation> binaryAnnotationList = createZipkinBinaryAnnotations(hTraceSpan, ep); zipkinSpan.setTrace_id(hTraceSpan.getSpanId().getHigh()); if (hTraceSpan.getParents().length > 0) { if (hTraceSpan.getParents().length > 1) { LOG.error("zipkin doesn't support spans with multiple parents. Omitting " + "other parents for " + hTraceSpan); } zipkinSpan.setParent_id(hTraceSpan.getParents()[0].getLow()); } zipkinSpan.setId(hTraceSpan.getSpanId().getLow()); zipkinSpan.setName(hTraceSpan.getDescription()); zipkinSpan.setAnnotations(annotationList); zipkinSpan.setBinary_annotations(binaryAnnotationList); return zipkinSpan; }
public static void appendJsonString(Span span, OutputStreamWriter writer) throws IOException { writer.append("{"); appendField(JSON_FIELD_TRACE_ID, span.getSpanId().getLow(), writer); appendField(JSON_FIELD_SPAN_ID, span.getSpanId().getHigh(), writer); appendField(JSON_FIELD_DESCRIPTION, span.getDescription(), writer); if (span.getParents().length != 0) { appendField(JSON_FIELD_PARENT_ID, span.getParents()[0].getLow(), writer); } appendField(JSON_FIELD_START, span.getStartTimeMillis(), writer); appendField(JSON_FIELD_STOP, span.getStopTimeMillis(), writer); if (!span.getTimelineAnnotations().isEmpty()) { writer.append("\""); writer.append(JSON_FIELD_TIMELINE); writer.append("\""); writer.append(":"); writer.append("["); for (TimelineAnnotation annotation : span.getTimelineAnnotations()) { writer.append("{"); appendField(JSON_FIELD_TIMELINE_TIME, annotation.getTime(), writer); appendField(JSON_FIELD_TIMELINE_MESSEGE, annotation.getMessage(), writer); writer.append("}"); } writer.append("]"); } writer.append("}"); }
@Test(timeout=60000) public void testRootSpansHaveNonZeroSpanId() throws Exception { Tracer tracer = new Tracer.Builder(). name("testRootSpansHaveNonZeroSpanId"). tracerPool(new TracerPool("testRootSpansHaveNonZeroSpanId")). conf(HTraceConfiguration.fromKeyValuePairs( "sampler.classes", "AlwaysSampler")).build(); TraceScope scope = tracer. newScope("myRootSpan", new SpanId(100L, 200L)); Assert.assertNotNull(scope); Assert.assertEquals("myRootSpan", scope.getSpan().getDescription()); Assert.assertTrue(scope.getSpan().getSpanId().isValid()); Assert.assertEquals(100L, scope.getSpan().getSpanId().getHigh()); Assert.assertNotEquals(0L, scope.getSpan().getSpanId().getLow()); scope.close(); } }
spanRow.addString(column_span_description, span.getDescription()); session.apply(spanInsert); long annotationCounter = 0;