/** * Add a result to this aggregate result. * @param time Time in nanoseconds * @param span Span. To be kept if the time taken was over 1 second */ public void addResult(long time, Span span) { if (span == null) { return; } stats.addValue(TimeUnit.MILLISECONDS.convert(time, TimeUnit.NANOSECONDS)); if (TimeUnit.SECONDS.convert(time, TimeUnit.NANOSECONDS) >= 1) { traces.add(span.getTracerId()); } }
/** * Add a result to this aggregate result. * @param time Time in nanoseconds * @param span Span. To be kept if the time taken was over 1 second */ public void addResult(long time, Span span) { if (span == null) { return; } stats.addValue(TimeUnit.MILLISECONDS.convert(time, TimeUnit.NANOSECONDS)); if (TimeUnit.SECONDS.convert(time, TimeUnit.NANOSECONDS) >= 1) { traces.add(span.getTracerId()); } }
@Override public int compare(Span a, Span b) { int cmp = a.getTracerId().compareTo(b.getTracerId()); if (cmp != 0) { return cmp; } return a.getSpanId().compareTo(b.getSpanId()); } };
headers.put("TracerId", span.getTracerId()); headers.put("Description", span.getDescription());
public List<Span> find(String tracerId) { List<Span> spans = new ArrayList<Span>(); Span span = new MilliSpan.Builder(). spanId(SpanId.INVALID). tracerId(tracerId). build(); while (true) { span = treeSet.higher(span); if (span == null) { break; } if (span.getTracerId().equals(tracerId)) { break; } spans.add(span); } return spans; }
jgen.writeStringField("d", span.getDescription()); String tracerId = span.getTracerId(); if (!tracerId.isEmpty()) { jgen.writeStringField("r", tracerId);
jgen.writeStringField("d", span.getDescription()); String tracerId = span.getTracerId(); if (!tracerId.isEmpty()) { jgen.writeStringField("r", tracerId);
jgen.writeStringField("d", span.getDescription()); String tracerId = span.getTracerId(); if (!tracerId.isEmpty()) { jgen.writeStringField("r", tracerId);
assertEquals(expected.getDescription(), got.getDescription()); assertEquals(expected.getSpanId(), got.getSpanId()); assertEquals(expected.getTracerId(), got.getTracerId()); assertTrue(Arrays.equals(expected.getParents(), got.getParents())); Map<String, String> expectedT = expected.getKVAnnotations();
.setStop(span.getStopTimeMillis()) .setSpanId(span.getSpanId().getLow()) .setProcessId(span.getTracerId()) .setDescription(span.getDescription());
/** * 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; }