public SpanId build() { return new SpanId(this); }
/** Deserializes this from a big-endian byte array */ public static SpanId fromBytes(byte[] bytes) { checkNotNull(bytes, "bytes"); if (bytes.length != 32) { throw new IllegalArgumentException("bytes.length " + bytes.length + " != 32"); } ByteBuffer buffer = ByteBuffer.wrap(bytes); long spanId = buffer.getLong(0); long parentId = buffer.getLong(8); long traceId = buffer.getLong(16); long flags = buffer.getLong(24); return new SpanId(traceId, parentId, spanId, flags); }
public SpanId build() { long traceId = this.traceId != null ? this.traceId : checkNotNull(spanId, "spanId"); long parentId = this.parentId != null ? this.parentId : traceId; return new SpanId(traceId, parentId, checkNotNull(spanId, "spanId"), flags); } }
/** Deserializes this from a big-endian byte array */ public static SpanId fromBytes(byte[] bytes) { checkNotNull(bytes, "bytes"); if (bytes.length != 32 && bytes.length != 40) { throw new IllegalArgumentException("bytes.length " + bytes.length + " != 32 or 40"); } ByteBuffer buffer = ByteBuffer.wrap(bytes); Builder builder = new Builder(); builder.spanId(buffer.getLong(0)); builder.parentId(buffer.getLong(8)); if (bytes.length == 32) { builder.traceId(buffer.getLong(16)); builder.flags(buffer.getLong(24)); } else { builder.traceIdHigh(buffer.getLong(16)); builder.traceId(buffer.getLong(24)); builder.flags(buffer.getLong(32)); } return new SpanId(builder); }