@Override public boolean isRoot(Span span) { // TODO replace with Span#unwrap once https://github.com/opentracing/opentracing-java/pull/211 is merged if (span instanceof SpanWrapper) { span = ((SpanWrapper) span).getDelegate(); } if (span instanceof BraveSpan) { final BraveSpan braveSpan = (BraveSpan) span; return braveSpan.unwrap().context().parentId() == null; } return false; }
MDC.put("traceId", traceIdString); MDC.put(LEGACY_TRACE_ID_NAME, traceIdString); String parentId = currentSpan.parentId() != null ? HexCodec.toLowerHex(currentSpan.parentId()) : null; replace("parentId", parentId); replace(LEGACY_PARENT_ID_NAME, parentId); MDC.put(LEGACY_EXPORTABLE_NAME, sampled); log("Starting scope for span: {}", currentSpan); if (currentSpan.parentId() != null) { if (log.isTraceEnabled()) { log.trace("With parent: {}", currentSpan.parentId());
MDC.put("traceId", traceIdString); MDC.put(LEGACY_TRACE_ID_NAME, traceIdString); String parentId = currentSpan.parentId() != null ? HexCodec.toLowerHex(currentSpan.parentId()) : null; replace("parentId", parentId); replace(LEGACY_PARENT_ID_NAME, parentId); MDC.put(LEGACY_EXPORTABLE_NAME, sampled); log("Starting scope for span: {}", currentSpan); if (currentSpan.parentId() != null) { if (log.isTraceEnabled()) { log.trace("With parent: {}", currentSpan.parentId());
private void serverResponse(Tracing brave, String serviceName, Exchange exchange) { Span span = null; ZipkinState state = exchange.getProperty(ZipkinState.KEY, ZipkinState.class); if (state != null) { // only process if it was a zipkin server event span = state.popServerSpan(); } if (span != null) { ZipkinServerResponseAdapter parser = new ZipkinServerResponseAdapter(this, exchange); parser.onResponse(exchange, span.customizer()); span.finish(); TraceContext context = span.context(); String traceId = "" + context.traceIdString(); String spanId = "" + context.spanId(); String parentId = context.parentId() != null ? "" + context.parentId() : null; if (camelContext.isUseMDCLogging()) { MDC.put("traceId", traceId); MDC.put("spanId", spanId); MDC.put("parentId", parentId); } if (LOG.isDebugEnabled()) { if (parentId != null) { LOG.debug(String.format("serverResponse[service=%s, traceId=%20s, spanId=%20s, parentId=%20s]", serviceName, traceId, spanId, parentId)); } else { LOG.debug(String.format("serverResponse[service=%s, traceId=%20s, spanId=%20s]", serviceName, traceId, spanId)); } } } }
public void propagationTraceInfo(HttpUriRequest request, Span span) { TraceContext currentSpan = span.context(); request.addHeader("X-B3-TraceId",currentSpan.traceIdString()); request.addHeader("X-B3-SpanId", HexCodec.toLowerHex(currentSpan.spanId())); if(currentSpan.parentId() != null) { request.addHeader("X-B3-ParentSpanId", HexCodec.toLowerHex(currentSpan.parentId())); } request.addHeader("X-B3-Sampled",String.valueOf(currentSpan.sampled())); }
private void clientResponse(Tracing brave, String serviceName, ExchangeSentEvent event) { Span span = null; ZipkinState state = event.getExchange().getProperty(ZipkinState.KEY, ZipkinState.class); if (state != null) { // only process if it was a zipkin client event span = state.popClientSpan(); } if (span != null) { ZipkinClientResponseAdaptor parser = new ZipkinClientResponseAdaptor(this, event.getEndpoint()); parser.onResponse(event.getExchange(), span.customizer()); span.finish(); TraceContext context = span.context(); String traceId = "" + context.traceIdString(); String spanId = "" + context.spanId(); String parentId = context.parentId() != null ? "" + context.parentId() : null; if (camelContext.isUseMDCLogging()) { MDC.put("traceId", traceId); MDC.put("spanId", spanId); MDC.put("parentId", parentId); } if (LOG.isDebugEnabled()) { if (parentId != null) { LOG.debug(String.format("clientResponse[service=%s, traceId=%20s, spanId=%20s, parentId=%20s]", serviceName, traceId, spanId, parentId)); } else { LOG.debug(String.format("clientResponse[service=%s, traceId=%20s, spanId=%20s]", serviceName, traceId, spanId)); } } } }
MDC.put("traceId", traceIdString); MDC.put(LEGACY_TRACE_ID_NAME, traceIdString); String parentId = currentSpan.parentId() != null ? HexCodec.toLowerHex(currentSpan.parentId()) : null; replace("parentId", parentId); replace(LEGACY_PARENT_ID_NAME, parentId); MDC.put(LEGACY_EXPORTABLE_NAME, sampled); log("Starting scope for span: {}", currentSpan); if (currentSpan.parentId() != null) { if (log.isTraceEnabled()) { log.trace("With parent: {}", currentSpan.parentId());
MDC.put("traceId", traceIdString); MDC.put(LEGACY_TRACE_ID_NAME, traceIdString); String parentId = currentSpan.parentId() != null ? HexCodec.toLowerHex(currentSpan.parentId()) : null; replace("parentId", parentId); replace(LEGACY_PARENT_ID_NAME, parentId); MDC.put(LEGACY_EXPORTABLE_NAME, sampled); log("Starting scope for span: {}", currentSpan); if (currentSpan.parentId() != null) { if (log.isTraceEnabled()) { log.trace("With parent: {}", currentSpan.parentId());
span.context().parentId(), span.context().spanId());
static SpanId toSpanId(TraceContext context) { return SpanId.builder() .traceIdHigh(context.traceIdHigh()) .traceId(context.traceId()) .parentId(context.parentId()) .spanId(context.spanId()) .debug(context.debug()) .sampled(context.sampled()).build(); } }
logger.info("consumer:traceId={},parentId={},spanId={}", span.context().traceId(), span.context().parentId(), span.context().spanId());