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

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

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

TraceContext.traceId介绍

[英]Unique 8-byte identifier for a trace, set on all spans within it.
[中]跟踪的唯一8字节标识符,设置在其中的所有跨距上。

代码示例

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

/** Resolves hash code collisions */
 @Override public boolean equals(Object other) {
  RealKey that = (RealKey) other;
  TraceContext thatContext = that.get();
  if (thatContext == null) return false;
  return (traceIdHigh == thatContext.traceIdHigh())
    && (traceId == thatContext.traceId())
    && (spanId == thatContext.spanId())
    && shared == thatContext.shared();
 }
}

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

public final TraceContext decorate(TraceContext context) {
 long traceId = context.traceId(), spanId = context.spanId();
 Class<E> type = type();

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

void set(TraceContext context) {
 set(context.traceIdHigh(), context.traceId(), context.spanId(), context.shared());
}

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

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

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

RealKey(TraceContext context, ReferenceQueue<TraceContext> queue) {
 super(context, queue);
 hashCode = context.hashCode();
 traceIdHigh = context.traceIdHigh();
 traceId = context.traceId();
 localRootId = context.localRootId();
 spanId = context.spanId();
 sampled = Boolean.TRUE.equals(context.sampled());
}

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

/** Trace contexts are equal only on trace ID and span ID. try to get the parent's clock */
@Nullable TickClock getClockFromParent(TraceContext context) {
 long parentId = context.parentIdAsLong();
 // NOTE: we still look for lookup key even on root span, as a client span can be root, and a
 // server can share the same ID. Essentially, a shared span is similar to a child.
 PendingSpan parent = null;
 if (context.shared() || parentId != 0L) {
  long spanId = parentId != 0L ? parentId : context.spanId();
  parent = delegate.get(InternalPropagation.instance.newTraceContext(
    0,
    context.traceIdHigh(),
    context.traceId(),
    0,
    0,
    spanId,
    Collections.emptyList()
  ));
 }
 return parent != null ? parent.clock : null;
}

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

static byte[] toBytes(TraceContext traceContext) {
 checkNotNull(traceContext, "traceContext");
 byte[] bytes = new byte[FORMAT_LENGTH];
 bytes[0] = VERSION;
 bytes[1] = TRACE_ID_FIELD_ID;
 writeLong(bytes, 2, traceContext.traceIdHigh());
 writeLong(bytes, 10, traceContext.traceId());
 bytes[18] = SPAN_ID_FIELD_ID;
 writeLong(bytes, 19, traceContext.spanId());
 bytes[27] = TRACE_OPTION_FIELD_ID;
 if (traceContext.sampled() != null && traceContext.sampled()) {
  bytes[28] = 1;
 }
 return bytes;
}

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

/**
 * Called by methods which can accept externally supplied parent trace contexts: Ex. {@link
 * #newChild(TraceContext)} and {@link #startScopedSpanWithParent(String, TraceContext)}. This
 * implies the {@link TraceContext#localRootId()} could be zero, if the context was manually
 * created.
 */
TraceContext nextContext(TraceContext parent) {
 return nextContext(
   InternalPropagation.instance.flags(parent),
   parent.traceIdHigh(),
   parent.traceId(),
   parent.localRootId(),
   parent.spanId(),
   parent.extra()
 );
}

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

static int writeB3SingleFormat(TraceContext context, long parentId, char[] result) {
 int pos = 0;
 long traceIdHigh = context.traceIdHigh();
 if (traceIdHigh != 0L) {
  writeHexLong(result, pos, traceIdHigh);
  pos += 16;
 }
 writeHexLong(result, pos, context.traceId());
 pos += 16;
 result[pos++] = '-';
 writeHexLong(result, pos, context.spanId());
 pos += 16;
 Boolean sampled = context.sampled();
 if (sampled != null) {
  result[pos++] = '-';
  result[pos++] = context.debug() ? 'd' : sampled ? '1' : '0';
 }
 if (parentId != 0L) {
  result[pos++] = '-';
  writeHexLong(result, pos, parentId);
  pos += 16;
 }
 return pos;
}

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

flags = InternalPropagation.sampled(sampler.isSampled(context.traceId()), flags);
} else if ((flags & FLAG_SAMPLED) == FLAG_SAMPLED) {
  flags | FLAG_LOCAL_ROOT,
  context.traceIdHigh(),
  context.traceId(),

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

traceId = implicitParent.traceId();
localRootId = implicitParent.localRootId();
spanId = implicitParent.spanId();

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

/** Resolves hash code collisions */
 @Override public boolean equals(Object other) {
  RealKey that = (RealKey) other;
  TraceContext thatContext = that.get();
  if (thatContext == null) return false;
  return (traceIdHigh == thatContext.traceIdHigh())
    && (traceId == thatContext.traceId())
    && (spanId == thatContext.spanId())
    && shared == thatContext.shared();
 }
}

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

void set(TraceContext context) {
 set(context.traceIdHigh(), context.traceId(), context.spanId(), context.shared());
}

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

RealKey(TraceContext context, ReferenceQueue<TraceContext> queue) {
 super(context, queue);
 hashCode = context.hashCode();
 traceIdHigh = context.traceIdHigh();
 traceId = context.traceId();
 localRootId = context.localRootId();
 spanId = context.spanId();
 sampled = Boolean.TRUE.equals(context.sampled());
}

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

/** Trace contexts are equal only on trace ID and span ID. try to get the parent's clock */
@Nullable TickClock getClockFromParent(TraceContext context) {
 long parentId = context.parentIdAsLong();
 // NOTE: we still look for lookup key even on root span, as a client span can be root, and a
 // server can share the same ID. Essentially, a shared span is similar to a child.
 PendingSpan parent = null;
 if (context.shared() || parentId != 0L) {
  long spanId = parentId != 0L ? parentId : context.spanId();
  parent = delegate.get(InternalPropagation.instance.newTraceContext(
    0,
    context.traceIdHigh(),
    context.traceId(),
    0,
    0,
    spanId,
    Collections.emptyList()
  ));
 }
 return parent != null ? parent.clock : null;
}

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

/**
 * Called by methods which can accept externally supplied parent trace contexts: Ex. {@link
 * #newChild(TraceContext)} and {@link #startScopedSpanWithParent(String, TraceContext)}. This
 * implies the {@link TraceContext#localRootId()} could be zero, if the context was manually
 * created.
 */
TraceContext nextContext(TraceContext parent) {
 return nextContext(
   InternalPropagation.instance.flags(parent),
   parent.traceIdHigh(),
   parent.traceId(),
   parent.localRootId(),
   parent.spanId(),
   parent.extra()
 );
}

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

static byte[] toBytes(TraceContext traceContext) {
 checkNotNull(traceContext, "traceContext");
 byte[] bytes = new byte[FORMAT_LENGTH];
 bytes[0] = VERSION;
 bytes[1] = TRACE_ID_FIELD_ID;
 writeLong(bytes, 2, traceContext.traceIdHigh());
 writeLong(bytes, 10, traceContext.traceId());
 bytes[18] = SPAN_ID_FIELD_ID;
 writeLong(bytes, 19, traceContext.spanId());
 bytes[27] = TRACE_OPTION_FIELD_ID;
 if (traceContext.sampled() != null && traceContext.sampled()) {
  bytes[28] = 1;
 }
 return bytes;
}

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

static int writeB3SingleFormat(TraceContext context, long parentId, char[] result) {
 int pos = 0;
 long traceIdHigh = context.traceIdHigh();
 if (traceIdHigh != 0L) {
  writeHexLong(result, pos, traceIdHigh);
  pos += 16;
 }
 writeHexLong(result, pos, context.traceId());
 pos += 16;
 result[pos++] = '-';
 writeHexLong(result, pos, context.spanId());
 pos += 16;
 Boolean sampled = context.sampled();
 if (sampled != null) {
  result[pos++] = '-';
  result[pos++] = context.debug() ? 'd' : sampled ? '1' : '0';
 }
 if (parentId != 0L) {
  result[pos++] = '-';
  writeHexLong(result, pos, parentId);
  pos += 16;
 }
 return pos;
}

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

/** Writes 35 characters representing the input trace ID to the buffer at the given offset */
static void writeRoot(TraceContext context, char[] result, int offset) {
 result[offset] = '1'; // version
 result[offset + 1] = '-'; // delimiter
 long high = context.traceIdHigh();
 writeHexByte(result, offset + 2, (byte) ((high >>> 56L) & 0xff));
 writeHexByte(result, offset + 4, (byte) ((high >>> 48L) & 0xff));
 writeHexByte(result, offset + 6, (byte) ((high >>> 40L) & 0xff));
 writeHexByte(result, offset + 8, (byte) ((high >>> 32L) & 0xff));
 result[offset + 10] = '-';
 writeHexByte(result, offset + 11, (byte) ((high >>> 24L) & 0xff));
 writeHexByte(result, offset + 13, (byte) ((high >>> 16L) & 0xff));
 writeHexByte(result, offset + 15, (byte) ((high >>> 8L) & 0xff));
 writeHexByte(result, offset + 17, (byte) (high & 0xff));
 writeHexLong(result, offset + 19, context.traceId());
}

代码示例来源: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();
 }
}

相关文章