brave.propagation.TraceContextOrSamplingFlags.equals()方法的使用及代码示例

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

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

TraceContextOrSamplingFlags.equals介绍

暂无

代码示例

代码示例来源:origin: openzipkin/brave

TraceContextOrSamplingFlags extractAndClearHeaders(Headers headers) {
 TraceContextOrSamplingFlags extracted = extractor.extract(headers);
 // clear propagation headers if we were able to extract a span
 if (!extracted.equals(TraceContextOrSamplingFlags.EMPTY)) {
  clearHeaders(headers);
 }
 return extracted;
}

代码示例来源:origin: openzipkin/brave

@Override public TraceContextOrSamplingFlags extract(C carrier) {
  if (carrier == null) throw new NullPointerException("carrier == null");
  // try to extract single-header format
  TraceContextOrSamplingFlags extracted = singleExtractor.extract(carrier);
  if (!extracted.equals(TraceContextOrSamplingFlags.EMPTY)) return extracted;
  // Start by looking at the sampled state as this is used regardless
  // Official sampled value is 1, though some old instrumentation send true
  String sampled = getter.get(carrier, propagation.sampledKey);
  Boolean sampledV = sampled != null
    ? sampled.equals("1") || sampled.equalsIgnoreCase("true")
    : null;
  boolean debug = "1".equals(getter.get(carrier, propagation.debugKey));
  String traceIdString = getter.get(carrier, propagation.traceIdKey);
  // It is ok to go without a trace ID, if sampling or debug is set
  if (traceIdString == null) return TraceContextOrSamplingFlags.create(sampledV, debug);
  // Try to parse the trace IDs into the context
  TraceContext.Builder result = TraceContext.newBuilder();
  if (result.parseTraceId(traceIdString, propagation.traceIdKey)
    && result.parseSpanId(getter, carrier, propagation.spanIdKey)
    && result.parseParentId(getter, carrier, propagation.parentSpanIdKey)) {
   if (sampledV != null) result.sampled(sampledV.booleanValue());
   if (debug) result.debug(true);
   return TraceContextOrSamplingFlags.create(result.build());
  }
  return TraceContextOrSamplingFlags.EMPTY; // trace context is malformed so return empty
 }
}

代码示例来源:origin: io.zipkin.brave/brave-instrumentation-kafka-clients

TraceContextOrSamplingFlags extractAndClearHeaders(Headers headers) {
 TraceContextOrSamplingFlags extracted = extractor.extract(headers);
 // clear propagation headers if we were able to extract a span
 if (!extracted.equals(TraceContextOrSamplingFlags.EMPTY)) {
  clearHeaders(headers);
 }
 return extracted;
}

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

@Override public TraceContextOrSamplingFlags extract(C carrier) {
  if (carrier == null) throw new NullPointerException("carrier == null");
  // try to extract single-header format
  TraceContextOrSamplingFlags extracted = singleExtractor.extract(carrier);
  if (!extracted.equals(TraceContextOrSamplingFlags.EMPTY)) return extracted;
  // Start by looking at the sampled state as this is used regardless
  // Official sampled value is 1, though some old instrumentation send true
  String sampled = getter.get(carrier, propagation.sampledKey);
  Boolean sampledV = sampled != null
    ? sampled.equals("1") || sampled.equalsIgnoreCase("true")
    : null;
  boolean debug = "1".equals(getter.get(carrier, propagation.debugKey));
  String traceIdString = getter.get(carrier, propagation.traceIdKey);
  // It is ok to go without a trace ID, if sampling or debug is set
  if (traceIdString == null) return TraceContextOrSamplingFlags.create(sampledV, debug);
  // Try to parse the trace IDs into the context
  TraceContext.Builder result = TraceContext.newBuilder();
  if (result.parseTraceId(traceIdString, propagation.traceIdKey)
    && result.parseSpanId(getter, carrier, propagation.spanIdKey)
    && result.parseParentId(getter, carrier, propagation.parentSpanIdKey)) {
   if (sampledV != null) result.sampled(sampledV.booleanValue());
   if (debug) result.debug(true);
   return TraceContextOrSamplingFlags.create(result.build());
  }
  return TraceContextOrSamplingFlags.EMPTY; // trace context is malformed so return empty
 }
}

相关文章