private static void ensureLocalComponent(Span span, Builder zipkinSpan, Endpoint ep) { if (span.tags().containsKey(Constants.LOCAL_COMPONENT)) { return; } String processId = span.getProcessId() != null ? span.getProcessId().toLowerCase() : ZipkinMessageListener.UNKNOWN_PROCESS_ID; zipkinSpan.addBinaryAnnotation( BinaryAnnotation.create(Constants.LOCAL_COMPONENT, processId, ep)); }
public static Message<?> addSpanHeaders(TraceKeys traceKeys, Message<?> message, Span span) { if (span == null) { if (!message.getHeaders().containsKey(Span.NOT_SAMPLED_NAME)) { return MessageBuilder.fromMessage(message).setHeader(Span.NOT_SAMPLED_NAME, "").build(); } return message; } Map<String, String> headers = new HashMap<>(); addHeader(headers, Span.TRACE_ID_NAME, Span.toHex(span.getTraceId())); addHeader(headers, Span.SPAN_ID_NAME, Span.toHex(span.getSpanId())); if (span.isExportable()) { addAnnotations(traceKeys, message, span); Long parentId = getFirst(span.getParents()); if (parentId != null) { addHeader(headers, Span.PARENT_ID_NAME, Span.toHex(parentId)); } addHeader(headers, Span.SPAN_NAME_NAME, span.getName()); addHeader(headers, Span.PROCESS_ID_NAME, span.getProcessId()); } else { addHeader(headers, Span.NOT_SAMPLED_NAME, ""); } return MessageBuilder.fromMessage(message).copyHeaders(headers).build(); }