brave.propagation.TraceContext.parentId()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中brave.propagation.TraceContext.parentId()方法的一些代码示例,展示了TraceContext.parentId()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TraceContext.parentId()方法的具体详情如下:
包路径:brave.propagation.TraceContext
类名称:TraceContext
方法名:parentId

TraceContext.parentId介绍

[英]The parent's #spanId or null if this the root span in a trace.
[中]父级的#spanId或null(如果这是跟踪中的根span)。

代码示例

代码示例来源:origin: stagemonitor/stagemonitor

@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;
}

代码示例来源:origin: spring-cloud/spring-cloud-sleuth

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());

代码示例来源:origin: spring-cloud/spring-cloud-sleuth

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());

代码示例来源:origin: org.apache.camel/camel-zipkin

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));
      }
    }
  }
}

代码示例来源:origin: com.github.gitssie/play-transport

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()));
}

代码示例来源:origin: org.apache.camel/camel-zipkin

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));
      }
    }
  }
}

代码示例来源:origin: org.springframework.cloud/spring-cloud-sleuth-core

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());

代码示例来源:origin: org.springframework.cloud/spring-cloud-sleuth-core

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());

代码示例来源:origin: org.apache.camel/camel-zipkin

String traceId = "" + context.traceIdString();
String spanId = "" + context.spanId();
String parentId = context.parentId() != null ? "" + context.parentId() : null;
if (camelContext.isUseMDCLogging()) {
  MDC.put("traceId", traceId);

代码示例来源:origin: org.apache.camel/camel-zipkin

String traceId = "" + context.traceIdString();
String spanId = "" + context.spanId();
String parentId = context.parentId() != null ? "" + context.parentId() : null;
if (camelContext.isUseMDCLogging()) {
  MDC.put("traceId", traceId);

代码示例来源:origin: jiangmin168168/jim-framework

span.context().parentId(),
span.context().spanId());

代码示例来源:origin: io.zipkin.brave/brave-core

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();
 }
}

代码示例来源:origin: jiangmin168168/jim-framework

logger.info("consumer:traceId={},parentId={},spanId={}",
    span.context().traceId(),
    span.context().parentId(),
    span.context().spanId());

相关文章