variableValues.add(span.getDescription());
@Override public void receiveSpan(Span s) { if (s.getStopTimeMillis() - s.getStartTimeMillis() < minSpanSize) { return; } Map<String,String> data = convertToStrings(s.getKVAnnotations()); SpanKey dest = getSpanKey(data); if (dest != null) { List<Annotation> annotations = convertToAnnotations(s.getTimelineAnnotations()); if (sendQueueSize.get() > maxQueueSize) { long now = System.currentTimeMillis(); if (now - lastNotificationOfDroppedSpans > 60 * 1000) { log.warn("Tracing spans are being dropped because there are already" + " {} spans queued for delivery.\n" + "This does not affect performance, security or data integrity," + " but distributed tracing information is being lost.", maxQueueSize); lastNotificationOfDroppedSpans = now; } return; } sendQueue.add(new RemoteSpan(host, service == null ? s.getProcessId() : service, s.getTraceId(), s.getSpanId(), s.getParentId(), s.getStartTimeMillis(), s.getStopTimeMillis(), s.getDescription(), data, annotations)); sendQueueSize.incrementAndGet(); } }
@Override public String description() { return span.getDescription(); }
public static Map<String, List<Span>> getMap() { Map<String, List<Span>> map = new HashMap<String, List<Span>>(); for (Span s : spans.values()) { List<Span> l = map.get(s.getDescription()); if (l == null) { l = new LinkedList<Span>(); map.put(s.getDescription(), l); } l.add(s); } return map; } }
variableValues.add(span.getDescription());
variableValues.add(span.getDescription());
@Override public void receiveSpan(Span s) { if (s.getStopTimeMillis() - s.getStartTimeMillis() < minSpanSize) { return; } Map<String,String> data = convertToStrings(s.getKVAnnotations()); SpanKey dest = getSpanKey(data); if (dest != null) { List<Annotation> annotations = convertToAnnotations(s.getTimelineAnnotations()); if (sendQueueSize.get() > maxQueueSize) { long now = System.currentTimeMillis(); if (now - lastNotificationOfDroppedSpans > 60 * 1000) { log.warn("Tracing spans are being dropped because there are already " + maxQueueSize + " spans queued for delivery.\n" + "This does not affect performance, security or data integrity," + " but distributed tracing information is being lost."); lastNotificationOfDroppedSpans = now; } return; } sendQueue.add(new RemoteSpan(host, service == null ? s.getProcessId() : service, s.getTraceId(), s.getSpanId(), s.getParentId(), s.getStartTimeMillis(), s.getStopTimeMillis(), s.getDescription(), data, annotations)); sendQueueSize.incrementAndGet(); } }
@Test public void testTracingInDataStreamer() throws Exception { DistributedFileSystem fs = cluster.getFileSystem(); FSDataOutputStream os = fs.create(new Path("/testTracingInDataStreamer")); byte[] bytes = "foo-bar-baz".getBytes(); try (TraceScope ts = Trace.startSpan("top level", Sampler.ALWAYS)) { os.write(bytes); os.hflush(); } assertSpanNamesFound(new String[]{ "writeTo" }); int spans1 = 0; for (Span s : SetSpanReceiver.SetHolder.spans.values()) { if (s.getDescription().equals("writeTo")) { spans1++; } } Assert.assertEquals(1, spans1); os.write(bytes); os.hflush(); os.close(); int spans2 = 0; for (Span s : SetSpanReceiver.SetHolder.spans.values()) { if (s.getDescription().equals("writeTo")) { spans2++; } } // If there are multiple "writeTo" spans, // spans are started in DataStreamer even after "top level" span is closed. Assert.assertEquals(spans1, spans2); }
jgen.writeNumberField("b", span.getStartTimeMillis()); jgen.writeNumberField("e", span.getStopTimeMillis()); jgen.writeStringField("d", span.getDescription()); jgen.writeStringField("r", span.getProcessId()); jgen.writeArrayFieldStart("p");