All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.twitter.finagle.thrift.thriftscala.Span.scala Maven / Gradle / Ivy

There is a newer version: 24.2.0
Show newest version
/**
 * Generated by Scrooge
 *   version: 20.4.1
 *   rev: 74d6bed636c90dc4b67e342ecd80033bad43e94d
 *   built at: 20200425-214521
 */
package com.twitter.finagle.thrift.thriftscala

import com.twitter.io.Buf
import com.twitter.scrooge.{
  InvalidFieldsException,
  LazyTProtocol,
  StructBuilder,
  StructBuilderFactory,
  TFieldBlob,
  ThriftStruct,
  ThriftStructCodec3,
  ThriftStructField,
  ThriftStructFieldInfo,
  ThriftStructMetaData,
  ValidatingThriftStruct,
  ValidatingThriftStructCodec3
}
import org.apache.thrift.protocol._
import org.apache.thrift.transport.TMemoryBuffer
import scala.collection.immutable.{Map => immutable$Map}
import scala.collection.mutable.Builder
import scala.reflect.{ClassTag, classTag}

/**
 * A trace is a series of spans (often RPC calls) which form a latency tree.
 *
 * The root span is where trace_id = id and parent_id = Nil. The root span is
 * usually the longest interval in the trace, starting with a SERVER_RECV
 * annotation and ending with a SERVER_SEND.
 */
object Span extends ValidatingThriftStructCodec3[Span] with StructBuilderFactory[Span] {
  val NoPassthroughFields: immutable$Map[Short, TFieldBlob] = immutable$Map.empty[Short, TFieldBlob]
  val Struct: TStruct = new TStruct("Span")
  val TraceIdField: TField = new TField("trace_id", TType.I64, 1)
  val TraceIdFieldManifest: Manifest[Long] = manifest[Long]
  val NameField: TField = new TField("name", TType.STRING, 3)
  val NameFieldManifest: Manifest[String] = manifest[String]
  val IdField: TField = new TField("id", TType.I64, 4)
  val IdFieldManifest: Manifest[Long] = manifest[Long]
  val ParentIdField: TField = new TField("parent_id", TType.I64, 5)
  val ParentIdFieldManifest: Manifest[Long] = manifest[Long]
  val AnnotationsField: TField = new TField("annotations", TType.LIST, 6)
  val AnnotationsFieldManifest: Manifest[_root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Annotation]] = manifest[_root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Annotation]]
  val BinaryAnnotationsField: TField = new TField("binary_annotations", TType.LIST, 8)
  val BinaryAnnotationsFieldManifest: Manifest[_root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.BinaryAnnotation]] = manifest[_root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.BinaryAnnotation]]
  val DebugField: TField = new TField("debug", TType.BOOL, 9)
  val DebugFieldManifest: Manifest[Boolean] = manifest[Boolean]
  val TimestampField: TField = new TField("timestamp", TType.I64, 10)
  val TimestampFieldManifest: Manifest[Long] = manifest[Long]
  val DurationField: TField = new TField("duration", TType.I64, 11)
  val DurationFieldManifest: Manifest[Long] = manifest[Long]
  val TraceIdHighField: TField = new TField("trace_id_high", TType.I64, 12)
  val TraceIdHighFieldManifest: Manifest[Long] = manifest[Long]

  /**
   * Field information in declaration order.
   */
  lazy val fieldInfos: scala.List[ThriftStructFieldInfo] = scala.List[ThriftStructFieldInfo](
    new ThriftStructFieldInfo(
      TraceIdField,
      false,
      false,
      TraceIdFieldManifest,
      _root_.scala.None,
      _root_.scala.None,
      immutable$Map.empty[String, String],
      immutable$Map.empty[String, String],
      None
    ),
    new ThriftStructFieldInfo(
      NameField,
      false,
      false,
      NameFieldManifest,
      _root_.scala.None,
      _root_.scala.None,
      immutable$Map.empty[String, String],
      immutable$Map.empty[String, String],
      None
    ),
    new ThriftStructFieldInfo(
      IdField,
      false,
      false,
      IdFieldManifest,
      _root_.scala.None,
      _root_.scala.None,
      immutable$Map.empty[String, String],
      immutable$Map.empty[String, String],
      None
    ),
    new ThriftStructFieldInfo(
      ParentIdField,
      true,
      false,
      ParentIdFieldManifest,
      _root_.scala.None,
      _root_.scala.None,
      immutable$Map.empty[String, String],
      immutable$Map.empty[String, String],
      None
    ),
    new ThriftStructFieldInfo(
      AnnotationsField,
      false,
      false,
      AnnotationsFieldManifest,
      _root_.scala.None,
      _root_.scala.Some(manifest[com.twitter.finagle.thrift.thriftscala.Annotation]),
      immutable$Map.empty[String, String],
      immutable$Map.empty[String, String],
      None
    ),
    new ThriftStructFieldInfo(
      BinaryAnnotationsField,
      false,
      false,
      BinaryAnnotationsFieldManifest,
      _root_.scala.None,
      _root_.scala.Some(manifest[com.twitter.finagle.thrift.thriftscala.BinaryAnnotation]),
      immutable$Map.empty[String, String],
      immutable$Map.empty[String, String],
      None
    ),
    new ThriftStructFieldInfo(
      DebugField,
      false,
      false,
      DebugFieldManifest,
      _root_.scala.None,
      _root_.scala.None,
      immutable$Map.empty[String, String],
      immutable$Map.empty[String, String],
      None
    ),
    new ThriftStructFieldInfo(
      TimestampField,
      true,
      false,
      TimestampFieldManifest,
      _root_.scala.None,
      _root_.scala.None,
      immutable$Map.empty[String, String],
      immutable$Map.empty[String, String],
      None
    ),
    new ThriftStructFieldInfo(
      DurationField,
      true,
      false,
      DurationFieldManifest,
      _root_.scala.None,
      _root_.scala.None,
      immutable$Map.empty[String, String],
      immutable$Map.empty[String, String],
      None
    ),
    new ThriftStructFieldInfo(
      TraceIdHighField,
      true,
      false,
      TraceIdHighFieldManifest,
      _root_.scala.None,
      _root_.scala.None,
      immutable$Map.empty[String, String],
      immutable$Map.empty[String, String],
      None
    )
  )


  val structAnnotations: immutable$Map[String, String] =
    immutable$Map.empty[String, String]

  private val fieldTypes: IndexedSeq[ClassTag[_]] = IndexedSeq[ClassTag[_]](
    classTag[Long].asInstanceOf[ClassTag[_]],
    classTag[String].asInstanceOf[ClassTag[_]],
    classTag[Long].asInstanceOf[ClassTag[_]],
    classTag[_root_.scala.Option[Long]].asInstanceOf[ClassTag[_]],
    classTag[_root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Annotation]].asInstanceOf[ClassTag[_]],
    classTag[_root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.BinaryAnnotation]].asInstanceOf[ClassTag[_]],
    classTag[Boolean].asInstanceOf[ClassTag[_]],
    classTag[_root_.scala.Option[Long]].asInstanceOf[ClassTag[_]],
    classTag[_root_.scala.Option[Long]].asInstanceOf[ClassTag[_]],
    classTag[_root_.scala.Option[Long]].asInstanceOf[ClassTag[_]]
  )

  private[this] val structFields: Seq[ThriftStructField[Span]] = Seq[ThriftStructField[Span]](
    new ThriftStructField[Span](
      TraceIdField,
      _root_.scala.Some(TraceIdFieldManifest),
      classOf[Span]) {
        def getValue[R](struct: Span): R = struct.traceId.asInstanceOf[R]
    },
    new ThriftStructField[Span](
      NameField,
      _root_.scala.Some(NameFieldManifest),
      classOf[Span]) {
        def getValue[R](struct: Span): R = struct.name.asInstanceOf[R]
    },
    new ThriftStructField[Span](
      IdField,
      _root_.scala.Some(IdFieldManifest),
      classOf[Span]) {
        def getValue[R](struct: Span): R = struct.id.asInstanceOf[R]
    },
    new ThriftStructField[Span](
      ParentIdField,
      _root_.scala.Some(ParentIdFieldManifest),
      classOf[Span]) {
        def getValue[R](struct: Span): R = struct.parentId.asInstanceOf[R]
    },
    new ThriftStructField[Span](
      AnnotationsField,
      _root_.scala.Some(AnnotationsFieldManifest),
      classOf[Span]) {
        def getValue[R](struct: Span): R = struct.annotations.asInstanceOf[R]
    },
    new ThriftStructField[Span](
      BinaryAnnotationsField,
      _root_.scala.Some(BinaryAnnotationsFieldManifest),
      classOf[Span]) {
        def getValue[R](struct: Span): R = struct.binaryAnnotations.asInstanceOf[R]
    },
    new ThriftStructField[Span](
      DebugField,
      _root_.scala.Some(DebugFieldManifest),
      classOf[Span]) {
        def getValue[R](struct: Span): R = struct.debug.asInstanceOf[R]
    },
    new ThriftStructField[Span](
      TimestampField,
      _root_.scala.Some(TimestampFieldManifest),
      classOf[Span]) {
        def getValue[R](struct: Span): R = struct.timestamp.asInstanceOf[R]
    },
    new ThriftStructField[Span](
      DurationField,
      _root_.scala.Some(DurationFieldManifest),
      classOf[Span]) {
        def getValue[R](struct: Span): R = struct.duration.asInstanceOf[R]
    },
    new ThriftStructField[Span](
      TraceIdHighField,
      _root_.scala.Some(TraceIdHighFieldManifest),
      classOf[Span]) {
        def getValue[R](struct: Span): R = struct.traceIdHigh.asInstanceOf[R]
    }
  )

  override lazy val metaData: ThriftStructMetaData[Span] =
    new ThriftStructMetaData(this, structFields, fieldInfos, Nil, structAnnotations)

  /**
   * Checks that all required fields are non-null.
   */
  def validate(_item: Span): Unit = {
  }

  /**
   * Checks that the struct is a valid as a new instance. If there are any missing required or
   * construction required fields, return a non-empty list.
   */
  def validateNewInstance(item: Span): scala.Seq[com.twitter.scrooge.validation.Issue] = {
    val buf = scala.collection.mutable.ListBuffer.empty[com.twitter.scrooge.validation.Issue]

    buf ++= validateField(item.traceId)
    buf ++= validateField(item.name)
    buf ++= validateField(item.id)
    buf ++= validateField(item.parentId)
    buf ++= validateField(item.annotations)
    buf ++= validateField(item.binaryAnnotations)
    buf ++= validateField(item.debug)
    buf ++= validateField(item.timestamp)
    buf ++= validateField(item.duration)
    buf ++= validateField(item.traceIdHigh)
    buf.toList
  }

  def withoutPassthroughFields(original: Span): Span =
    new Immutable(
      traceId = original.traceId,
      name = original.name,
      id = original.id,
      parentId = original.parentId,
      annotations =
        {
          val field = original.annotations
          field.map { field =>
            com.twitter.finagle.thrift.thriftscala.Annotation.withoutPassthroughFields(field)
          }
        },
      binaryAnnotations =
        {
          val field = original.binaryAnnotations
          field.map { field =>
            com.twitter.finagle.thrift.thriftscala.BinaryAnnotation.withoutPassthroughFields(field)
          }
        },
      debug = original.debug,
      timestamp = original.timestamp,
      duration = original.duration,
      traceIdHigh = original.traceIdHigh
    )

  def newBuilder(): StructBuilder[Span] = new SpanStructBuilder(_root_.scala.None, fieldTypes)

  override def encode(_item: Span, _oproto: TProtocol): Unit = {
    _item.write(_oproto)
  }


  private[this] def lazyDecode(_iprot: LazyTProtocol): Span = {

    var traceId: Long = 0L
    var nameOffset: Int = -1
    var id: Long = 0L
    var parent_idOffset: Int = -1
    var annotations: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Annotation] = _root_.scala.collection.immutable.Nil
    var binaryAnnotations: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.BinaryAnnotation] = _root_.scala.collection.immutable.Nil
    var debug: Boolean = false
    var timestampOffset: Int = -1
    var durationOffset: Int = -1
    var trace_id_highOffset: Int = -1

    var _passthroughFields: Builder[(Short, TFieldBlob), immutable$Map[Short, TFieldBlob]] = null
    var _done = false
    val _start_offset = _iprot.offset

    _iprot.readStructBegin()
    do {
      val _field = _iprot.readFieldBegin()
      val _fieldType = _field.`type`
      if (_fieldType == TType.STOP) {
        _done = true
      } else {
        _field.id match {
          case 1 =>
            if (_fieldType == TType.I64) {
              traceId = readTraceIdValue(_iprot)
            } else {
              _root_.com.twitter.scrooge.internal.ApplicationExceptions.throwWrongFieldTypeException(
                "Received wrong type for field 'traceId' (expected=%s, actual=%s).",
                TType.I64,
                _fieldType
              )
            }
          case 3 =>
            if (_fieldType == TType.STRING) {
              nameOffset = _iprot.offsetSkipString()
            } else {
              _root_.com.twitter.scrooge.internal.ApplicationExceptions.throwWrongFieldTypeException(
                "Received wrong type for field 'name' (expected=%s, actual=%s).",
                TType.STRING,
                _fieldType
              )
            }
          case 4 =>
            if (_fieldType == TType.I64) {
              id = readIdValue(_iprot)
            } else {
              _root_.com.twitter.scrooge.internal.ApplicationExceptions.throwWrongFieldTypeException(
                "Received wrong type for field 'id' (expected=%s, actual=%s).",
                TType.I64,
                _fieldType
              )
            }
          case 5 =>
            if (_fieldType == TType.I64) {
              parent_idOffset = _iprot.offsetSkipI64()
            } else {
              _root_.com.twitter.scrooge.internal.ApplicationExceptions.throwWrongFieldTypeException(
                "Received wrong type for field 'parentId' (expected=%s, actual=%s).",
                TType.I64,
                _fieldType
              )
            }
          case 6 =>
            if (_fieldType == TType.LIST) {
              annotations = readAnnotationsValue(_iprot)
            } else {
              _root_.com.twitter.scrooge.internal.ApplicationExceptions.throwWrongFieldTypeException(
                "Received wrong type for field 'annotations' (expected=%s, actual=%s).",
                TType.LIST,
                _fieldType
              )
            }
          case 8 =>
            if (_fieldType == TType.LIST) {
              binaryAnnotations = readBinaryAnnotationsValue(_iprot)
            } else {
              _root_.com.twitter.scrooge.internal.ApplicationExceptions.throwWrongFieldTypeException(
                "Received wrong type for field 'binaryAnnotations' (expected=%s, actual=%s).",
                TType.LIST,
                _fieldType
              )
            }
          case 9 =>
            if (_fieldType == TType.BOOL) {
              debug = readDebugValue(_iprot)
            } else {
              _root_.com.twitter.scrooge.internal.ApplicationExceptions.throwWrongFieldTypeException(
                "Received wrong type for field 'debug' (expected=%s, actual=%s).",
                TType.BOOL,
                _fieldType
              )
            }
          case 10 =>
            if (_fieldType == TType.I64) {
              timestampOffset = _iprot.offsetSkipI64()
            } else {
              _root_.com.twitter.scrooge.internal.ApplicationExceptions.throwWrongFieldTypeException(
                "Received wrong type for field 'timestamp' (expected=%s, actual=%s).",
                TType.I64,
                _fieldType
              )
            }
          case 11 =>
            if (_fieldType == TType.I64) {
              durationOffset = _iprot.offsetSkipI64()
            } else {
              _root_.com.twitter.scrooge.internal.ApplicationExceptions.throwWrongFieldTypeException(
                "Received wrong type for field 'duration' (expected=%s, actual=%s).",
                TType.I64,
                _fieldType
              )
            }
          case 12 =>
            if (_fieldType == TType.I64) {
              trace_id_highOffset = _iprot.offsetSkipI64()
            } else {
              _root_.com.twitter.scrooge.internal.ApplicationExceptions.throwWrongFieldTypeException(
                "Received wrong type for field 'traceIdHigh' (expected=%s, actual=%s).",
                TType.I64,
                _fieldType
              )
            }
          case _ =>
            if (_passthroughFields eq null)
              _passthroughFields = immutable$Map.newBuilder[Short, TFieldBlob]
            _passthroughFields += _root_.scala.Tuple2(_field.id, TFieldBlob.read(_field, _iprot))
        }
        _iprot.readFieldEnd()
      }
    } while (!_done)
    _iprot.readStructEnd()

    new LazyImmutable(
      _iprot,
      _iprot.buffer,
      _start_offset,
      _iprot.offset,
      traceId,
      nameOffset,
      id,
      parent_idOffset,
      annotations,
      binaryAnnotations,
      debug,
      timestampOffset,
      durationOffset,
      trace_id_highOffset,
      if (_passthroughFields eq null)
        NoPassthroughFields
      else
        _passthroughFields.result()
    )
  }

  override def decode(_iprot: TProtocol): Span = {
    if (_iprot.isInstanceOf[LazyTProtocol]) {
      lazyDecode(_iprot.asInstanceOf[LazyTProtocol])
    } else {
      eagerDecode(_iprot)
    }
  }

  private[thriftscala] def eagerDecode(_iprot: TProtocol): Span = {
    var traceId: Long = 0L
    var name: String = null
    var id: Long = 0L
    var parentId: _root_.scala.Option[Long] = _root_.scala.None
    var annotations: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Annotation] = _root_.scala.collection.immutable.Nil
    var binaryAnnotations: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.BinaryAnnotation] = _root_.scala.collection.immutable.Nil
    var debug: Boolean = false
    var timestamp: _root_.scala.Option[Long] = _root_.scala.None
    var duration: _root_.scala.Option[Long] = _root_.scala.None
    var traceIdHigh: _root_.scala.Option[Long] = _root_.scala.None
    var _passthroughFields: Builder[(Short, TFieldBlob), immutable$Map[Short, TFieldBlob]] = null
    var _done = false

    _iprot.readStructBegin()
    do {
      val _field = _iprot.readFieldBegin()
      val _fieldType = _field.`type`
      if (_fieldType == TType.STOP) {
        _done = true
      } else {
        _field.id match {
          case 1 =>
            if (_fieldType == TType.I64) {
              traceId = readTraceIdValue(_iprot)
            } else {
              _root_.com.twitter.scrooge.internal.ApplicationExceptions.throwWrongFieldTypeException(
                "Received wrong type for field 'traceId' (expected=%s, actual=%s).",
                TType.I64,
                _fieldType
              )
            }
          case 3 =>
            if (_fieldType == TType.STRING) {
              name = readNameValue(_iprot)
            } else {
              _root_.com.twitter.scrooge.internal.ApplicationExceptions.throwWrongFieldTypeException(
                "Received wrong type for field 'name' (expected=%s, actual=%s).",
                TType.STRING,
                _fieldType
              )
            }
          case 4 =>
            if (_fieldType == TType.I64) {
              id = readIdValue(_iprot)
            } else {
              _root_.com.twitter.scrooge.internal.ApplicationExceptions.throwWrongFieldTypeException(
                "Received wrong type for field 'id' (expected=%s, actual=%s).",
                TType.I64,
                _fieldType
              )
            }
          case 5 =>
            if (_fieldType == TType.I64) {
              parentId = _root_.scala.Some(readParentIdValue(_iprot))
            } else {
              _root_.com.twitter.scrooge.internal.ApplicationExceptions.throwWrongFieldTypeException(
                "Received wrong type for field 'parentId' (expected=%s, actual=%s).",
                TType.I64,
                _fieldType
              )
            }
          case 6 =>
            if (_fieldType == TType.LIST) {
              annotations = readAnnotationsValue(_iprot)
            } else {
              _root_.com.twitter.scrooge.internal.ApplicationExceptions.throwWrongFieldTypeException(
                "Received wrong type for field 'annotations' (expected=%s, actual=%s).",
                TType.LIST,
                _fieldType
              )
            }
          case 8 =>
            if (_fieldType == TType.LIST) {
              binaryAnnotations = readBinaryAnnotationsValue(_iprot)
            } else {
              _root_.com.twitter.scrooge.internal.ApplicationExceptions.throwWrongFieldTypeException(
                "Received wrong type for field 'binaryAnnotations' (expected=%s, actual=%s).",
                TType.LIST,
                _fieldType
              )
            }
          case 9 =>
            if (_fieldType == TType.BOOL) {
              debug = readDebugValue(_iprot)
            } else {
              _root_.com.twitter.scrooge.internal.ApplicationExceptions.throwWrongFieldTypeException(
                "Received wrong type for field 'debug' (expected=%s, actual=%s).",
                TType.BOOL,
                _fieldType
              )
            }
          case 10 =>
            if (_fieldType == TType.I64) {
              timestamp = _root_.scala.Some(readTimestampValue(_iprot))
            } else {
              _root_.com.twitter.scrooge.internal.ApplicationExceptions.throwWrongFieldTypeException(
                "Received wrong type for field 'timestamp' (expected=%s, actual=%s).",
                TType.I64,
                _fieldType
              )
            }
          case 11 =>
            if (_fieldType == TType.I64) {
              duration = _root_.scala.Some(readDurationValue(_iprot))
            } else {
              _root_.com.twitter.scrooge.internal.ApplicationExceptions.throwWrongFieldTypeException(
                "Received wrong type for field 'duration' (expected=%s, actual=%s).",
                TType.I64,
                _fieldType
              )
            }
          case 12 =>
            if (_fieldType == TType.I64) {
              traceIdHigh = _root_.scala.Some(readTraceIdHighValue(_iprot))
            } else {
              _root_.com.twitter.scrooge.internal.ApplicationExceptions.throwWrongFieldTypeException(
                "Received wrong type for field 'traceIdHigh' (expected=%s, actual=%s).",
                TType.I64,
                _fieldType
              )
            }
          case _ =>
            if (_passthroughFields eq null)
              _passthroughFields = immutable$Map.newBuilder[Short, TFieldBlob]
            _passthroughFields += _root_.scala.Tuple2(_field.id, TFieldBlob.read(_field, _iprot))
        }
        _iprot.readFieldEnd()
      }
    } while (!_done)
    _iprot.readStructEnd()

    new Immutable(
      traceId,
      name,
      id,
      parentId,
      annotations,
      binaryAnnotations,
      debug,
      timestamp,
      duration,
      traceIdHigh,
      if (_passthroughFields eq null)
        NoPassthroughFields
      else
        _passthroughFields.result()
    )
  }

  def apply(
    traceId: Long,
    name: String,
    id: Long,
    parentId: _root_.scala.Option[Long] = _root_.scala.None,
    annotations: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Annotation] = _root_.scala.collection.immutable.Nil,
    binaryAnnotations: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.BinaryAnnotation] = _root_.scala.collection.immutable.Nil,
    debug: Boolean,
    timestamp: _root_.scala.Option[Long] = _root_.scala.None,
    duration: _root_.scala.Option[Long] = _root_.scala.None,
    traceIdHigh: _root_.scala.Option[Long] = _root_.scala.None
  ): Span =
    new Immutable(
      traceId,
      name,
      id,
      parentId,
      annotations,
      binaryAnnotations,
      debug,
      timestamp,
      duration,
      traceIdHigh
    )

  def unapply(_item: Span): _root_.scala.Option[_root_.scala.Tuple10[Long, String, Long, Option[Long], _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Annotation], _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.BinaryAnnotation], Boolean, Option[Long], Option[Long], Option[Long]]] = _root_.scala.Some(_item.toTuple)


  @inline private[thriftscala] def readTraceIdValue(_iprot: TProtocol): Long = {
    _iprot.readI64()
  }

  @inline private def writeTraceIdField(traceId_item: Long, _oprot: TProtocol): Unit = {
    _oprot.writeFieldBegin(TraceIdField)
    writeTraceIdValue(traceId_item, _oprot)
    _oprot.writeFieldEnd()
  }

  @inline private def writeTraceIdValue(traceId_item: Long, _oprot: TProtocol): Unit = {
    _oprot.writeI64(traceId_item)
  }

  @inline private[thriftscala] def readNameValue(_iprot: TProtocol): String = {
    _iprot.readString()
  }

  @inline private def writeNameField(name_item: String, _oprot: TProtocol): Unit = {
    _oprot.writeFieldBegin(NameField)
    writeNameValue(name_item, _oprot)
    _oprot.writeFieldEnd()
  }

  @inline private def writeNameValue(name_item: String, _oprot: TProtocol): Unit = {
    _oprot.writeString(name_item)
  }

  @inline private[thriftscala] def readIdValue(_iprot: TProtocol): Long = {
    _iprot.readI64()
  }

  @inline private def writeIdField(id_item: Long, _oprot: TProtocol): Unit = {
    _oprot.writeFieldBegin(IdField)
    writeIdValue(id_item, _oprot)
    _oprot.writeFieldEnd()
  }

  @inline private def writeIdValue(id_item: Long, _oprot: TProtocol): Unit = {
    _oprot.writeI64(id_item)
  }

  @inline private[thriftscala] def readParentIdValue(_iprot: TProtocol): Long = {
    _iprot.readI64()
  }

  @inline private def writeParentIdField(parentId_item: Long, _oprot: TProtocol): Unit = {
    _oprot.writeFieldBegin(ParentIdField)
    writeParentIdValue(parentId_item, _oprot)
    _oprot.writeFieldEnd()
  }

  @inline private def writeParentIdValue(parentId_item: Long, _oprot: TProtocol): Unit = {
    _oprot.writeI64(parentId_item)
  }

  @inline private[thriftscala] def readAnnotationsValue(_iprot: TProtocol): _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Annotation] = {
    val _list = _iprot.readListBegin()
    if (_list.size == 0) {
      _iprot.readListEnd()
      Nil
    } else {
      val _rv = new _root_.scala.collection.mutable.ArrayBuffer[com.twitter.finagle.thrift.thriftscala.Annotation](_list.size)
      var _i = 0
      do {
        _rv += {
          com.twitter.finagle.thrift.thriftscala.Annotation.decode(_iprot)
        }
        _i += 1
      } while (_i < _list.size)
      _iprot.readListEnd()
      _rv
    }
  }

  @inline private def writeAnnotationsField(annotations_item: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Annotation], _oprot: TProtocol): Unit = {
    _oprot.writeFieldBegin(AnnotationsField)
    writeAnnotationsValue(annotations_item, _oprot)
    _oprot.writeFieldEnd()
  }

  @inline private def writeAnnotationsValue(annotations_item: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Annotation], _oprot: TProtocol): Unit = {
    _oprot.writeListBegin(new TList(TType.STRUCT, annotations_item.size))
    if (annotations_item.isInstanceOf[IndexedSeq[_]]) {
      var _i = 0
      val _size = annotations_item.size
      while (_i < _size) {
        val annotations_item_element = annotations_item(_i)
        annotations_item_element.write(_oprot)
        _i += 1
      }
    } else {
      annotations_item.foreach { annotations_item_element =>
        annotations_item_element.write(_oprot)
      }
    }
    _oprot.writeListEnd()
  }

  @inline private[thriftscala] def readBinaryAnnotationsValue(_iprot: TProtocol): _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.BinaryAnnotation] = {
    val _list = _iprot.readListBegin()
    if (_list.size == 0) {
      _iprot.readListEnd()
      Nil
    } else {
      val _rv = new _root_.scala.collection.mutable.ArrayBuffer[com.twitter.finagle.thrift.thriftscala.BinaryAnnotation](_list.size)
      var _i = 0
      do {
        _rv += {
          com.twitter.finagle.thrift.thriftscala.BinaryAnnotation.decode(_iprot)
        }
        _i += 1
      } while (_i < _list.size)
      _iprot.readListEnd()
      _rv
    }
  }

  @inline private def writeBinaryAnnotationsField(binaryAnnotations_item: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.BinaryAnnotation], _oprot: TProtocol): Unit = {
    _oprot.writeFieldBegin(BinaryAnnotationsField)
    writeBinaryAnnotationsValue(binaryAnnotations_item, _oprot)
    _oprot.writeFieldEnd()
  }

  @inline private def writeBinaryAnnotationsValue(binaryAnnotations_item: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.BinaryAnnotation], _oprot: TProtocol): Unit = {
    _oprot.writeListBegin(new TList(TType.STRUCT, binaryAnnotations_item.size))
    if (binaryAnnotations_item.isInstanceOf[IndexedSeq[_]]) {
      var _i = 0
      val _size = binaryAnnotations_item.size
      while (_i < _size) {
        val binaryAnnotations_item_element = binaryAnnotations_item(_i)
        binaryAnnotations_item_element.write(_oprot)
        _i += 1
      }
    } else {
      binaryAnnotations_item.foreach { binaryAnnotations_item_element =>
        binaryAnnotations_item_element.write(_oprot)
      }
    }
    _oprot.writeListEnd()
  }

  @inline private[thriftscala] def readDebugValue(_iprot: TProtocol): Boolean = {
    _iprot.readBool()
  }

  @inline private def writeDebugField(debug_item: Boolean, _oprot: TProtocol): Unit = {
    _oprot.writeFieldBegin(DebugField)
    writeDebugValue(debug_item, _oprot)
    _oprot.writeFieldEnd()
  }

  @inline private def writeDebugValue(debug_item: Boolean, _oprot: TProtocol): Unit = {
    _oprot.writeBool(debug_item)
  }

  @inline private[thriftscala] def readTimestampValue(_iprot: TProtocol): Long = {
    _iprot.readI64()
  }

  @inline private def writeTimestampField(timestamp_item: Long, _oprot: TProtocol): Unit = {
    _oprot.writeFieldBegin(TimestampField)
    writeTimestampValue(timestamp_item, _oprot)
    _oprot.writeFieldEnd()
  }

  @inline private def writeTimestampValue(timestamp_item: Long, _oprot: TProtocol): Unit = {
    _oprot.writeI64(timestamp_item)
  }

  @inline private[thriftscala] def readDurationValue(_iprot: TProtocol): Long = {
    _iprot.readI64()
  }

  @inline private def writeDurationField(duration_item: Long, _oprot: TProtocol): Unit = {
    _oprot.writeFieldBegin(DurationField)
    writeDurationValue(duration_item, _oprot)
    _oprot.writeFieldEnd()
  }

  @inline private def writeDurationValue(duration_item: Long, _oprot: TProtocol): Unit = {
    _oprot.writeI64(duration_item)
  }

  @inline private[thriftscala] def readTraceIdHighValue(_iprot: TProtocol): Long = {
    _iprot.readI64()
  }

  @inline private def writeTraceIdHighField(traceIdHigh_item: Long, _oprot: TProtocol): Unit = {
    _oprot.writeFieldBegin(TraceIdHighField)
    writeTraceIdHighValue(traceIdHigh_item, _oprot)
    _oprot.writeFieldEnd()
  }

  @inline private def writeTraceIdHighValue(traceIdHigh_item: Long, _oprot: TProtocol): Unit = {
    _oprot.writeI64(traceIdHigh_item)
  }


  object Immutable extends ThriftStructCodec3[Span] {
    override def encode(_item: Span, _oproto: TProtocol): Unit = { _item.write(_oproto) }
    override def decode(_iprot: TProtocol): Span = Span.decode(_iprot)
    override lazy val metaData: ThriftStructMetaData[Span] = Span.metaData
  }

  /**
   * The default read-only implementation of Span.  You typically should not need to
   * directly reference this class; instead, use the Span.apply method to construct
   * new instances.
   */
  class Immutable(
      val traceId: Long,
      val name: String,
      val id: Long,
      val parentId: _root_.scala.Option[Long],
      val annotations: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Annotation],
      val binaryAnnotations: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.BinaryAnnotation],
      val debug: Boolean,
      val timestamp: _root_.scala.Option[Long],
      val duration: _root_.scala.Option[Long],
      val traceIdHigh: _root_.scala.Option[Long],
      override val _passthroughFields: immutable$Map[Short, TFieldBlob])
    extends Span {
    def this(
      traceId: Long,
      name: String,
      id: Long,
      parentId: _root_.scala.Option[Long] = _root_.scala.None,
      annotations: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Annotation] = _root_.scala.collection.immutable.Nil,
      binaryAnnotations: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.BinaryAnnotation] = _root_.scala.collection.immutable.Nil,
      debug: Boolean,
      timestamp: _root_.scala.Option[Long] = _root_.scala.None,
      duration: _root_.scala.Option[Long] = _root_.scala.None,
      traceIdHigh: _root_.scala.Option[Long] = _root_.scala.None
    ) = this(
      traceId,
      name,
      id,
      parentId,
      annotations,
      binaryAnnotations,
      debug,
      timestamp,
      duration,
      traceIdHigh,
      immutable$Map.empty[Short, TFieldBlob]
    )
  }

  /**
   * This is another Immutable, this however keeps strings as lazy values that are lazily decoded from the backing
   * array byte on read.
   */
  private[this] class LazyImmutable(
      _proto: LazyTProtocol,
      _buf: Array[Byte],
      _start_offset: Int,
      _end_offset: Int,
      val traceId: Long,
      nameOffset: Int,
      val id: Long,
      parent_idOffset: Int,
      val annotations: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Annotation],
      val binaryAnnotations: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.BinaryAnnotation],
      val debug: Boolean,
      timestampOffset: Int,
      durationOffset: Int,
      trace_id_highOffset: Int,
      override val _passthroughFields: immutable$Map[Short, TFieldBlob])
    extends Span {

    override def write(_oprot: TProtocol): Unit = {
      if (_oprot.isInstanceOf[LazyTProtocol]) {
        _oprot.asInstanceOf[LazyTProtocol].writeRaw(_buf, _start_offset, _end_offset - _start_offset)
      } else {
        super.write(_oprot)
      }
    }

    lazy val name: String =
      if (nameOffset == -1)
        null
      else {
        _proto.decodeString(_buf, nameOffset)
      }
    lazy val parentId: _root_.scala.Option[Long] =
      if (parent_idOffset == -1)
        None
      else {
        Some(_proto.decodeI64(_buf, parent_idOffset))
      }
    lazy val timestamp: _root_.scala.Option[Long] =
      if (timestampOffset == -1)
        None
      else {
        Some(_proto.decodeI64(_buf, timestampOffset))
      }
    lazy val duration: _root_.scala.Option[Long] =
      if (durationOffset == -1)
        None
      else {
        Some(_proto.decodeI64(_buf, durationOffset))
      }
    lazy val traceIdHigh: _root_.scala.Option[Long] =
      if (trace_id_highOffset == -1)
        None
      else {
        Some(_proto.decodeI64(_buf, trace_id_highOffset))
      }

    /**
     * Override the super hash code to make it a lazy val rather than def.
     *
     * Calculating the hash code can be expensive, caching it where possible
     * can provide significant performance wins. (Key in a hash map for instance)
     * Usually not safe since the normal constructor will accept a mutable map or
     * set as an arg
     * Here however we control how the class is generated from serialized data.
     * With the class private and the contract that we throw away our mutable references
     * having the hash code lazy here is safe.
     */
    override lazy val hashCode: Int = super.hashCode
  }

  /**
   * This Proxy trait allows you to extend the Span trait with additional state or
   * behavior and implement the read-only methods from Span using an underlying
   * instance.
   */
  trait Proxy extends Span {
    protected def _underlying_Span: Span
    override def traceId: Long = _underlying_Span.traceId
    override def name: String = _underlying_Span.name
    override def id: Long = _underlying_Span.id
    override def parentId: _root_.scala.Option[Long] = _underlying_Span.parentId
    override def annotations: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Annotation] = _underlying_Span.annotations
    override def binaryAnnotations: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.BinaryAnnotation] = _underlying_Span.binaryAnnotations
    override def debug: Boolean = _underlying_Span.debug
    override def timestamp: _root_.scala.Option[Long] = _underlying_Span.timestamp
    override def duration: _root_.scala.Option[Long] = _underlying_Span.duration
    override def traceIdHigh: _root_.scala.Option[Long] = _underlying_Span.traceIdHigh
    override def _passthroughFields: immutable$Map[Short, TFieldBlob] = _underlying_Span._passthroughFields
  }
}

/**
 * Prefer the companion object's [[com.twitter.finagle.thrift.thriftscala.Span.apply]]
 * for construction if you don't need to specify passthrough fields.
 */
trait Span
  extends ThriftStruct
  with _root_.scala.Product10[Long, String, Long, Option[Long], _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Annotation], _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.BinaryAnnotation], Boolean, Option[Long], Option[Long], Option[Long]]
  with ValidatingThriftStruct[Span]
  with java.io.Serializable
{
  import Span._

  def traceId: Long
  def name: String
  def id: Long
  def parentId: _root_.scala.Option[Long]
  def annotations: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Annotation]
  def binaryAnnotations: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.BinaryAnnotation]
  def debug: Boolean
  def timestamp: _root_.scala.Option[Long]
  def duration: _root_.scala.Option[Long]
  def traceIdHigh: _root_.scala.Option[Long]

  def _passthroughFields: immutable$Map[Short, TFieldBlob] = immutable$Map.empty

  def _1: Long = traceId
  def _2: String = name
  def _3: Long = id
  def _4: _root_.scala.Option[Long] = parentId
  def _5: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Annotation] = annotations
  def _6: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.BinaryAnnotation] = binaryAnnotations
  def _7: Boolean = debug
  def _8: _root_.scala.Option[Long] = timestamp
  def _9: _root_.scala.Option[Long] = duration
  def _10: _root_.scala.Option[Long] = traceIdHigh

  def toTuple: _root_.scala.Tuple10[Long, String, Long, Option[Long], _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Annotation], _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.BinaryAnnotation], Boolean, Option[Long], Option[Long], Option[Long]] =
    _root_.scala.Tuple10[Long, String, Long, Option[Long], _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Annotation], _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.BinaryAnnotation], Boolean, Option[Long], Option[Long], Option[Long]](
      traceId,
      name,
      id,
      parentId,
      annotations,
      binaryAnnotations,
      debug,
      timestamp,
      duration,
      traceIdHigh
    )


  /**
   * Gets a field value encoded as a binary blob using TCompactProtocol.  If the specified field
   * is present in the passthrough map, that value is returned.  Otherwise, if the specified field
   * is known and not optional and set to None, then the field is serialized and returned.
   */
  def getFieldBlob(_fieldId: Short): _root_.scala.Option[TFieldBlob] = {
    val passedthroughValue = _passthroughFields.get(_fieldId)
    if (passedthroughValue.isDefined) {
      passedthroughValue
    } else {
      val _buff = new TMemoryBuffer(32)
      val _oprot = new TCompactProtocol(_buff)

      val _fieldOpt: _root_.scala.Option[TField] = _fieldId match {
        case 1 =>
            writeTraceIdValue(traceId, _oprot)
            _root_.scala.Some(Span.TraceIdField)
        case 3 =>
          if (name ne null) {
            writeNameValue(name, _oprot)
            _root_.scala.Some(Span.NameField)
          } else {
            _root_.scala.None
          }
        case 4 =>
            writeIdValue(id, _oprot)
            _root_.scala.Some(Span.IdField)
        case 5 =>
          if (parentId.isDefined) {
            writeParentIdValue(parentId.get, _oprot)
            _root_.scala.Some(Span.ParentIdField)
          } else {
            _root_.scala.None
          }
        case 6 =>
          if (annotations ne null) {
            writeAnnotationsValue(annotations, _oprot)
            _root_.scala.Some(Span.AnnotationsField)
          } else {
            _root_.scala.None
          }
        case 8 =>
          if (binaryAnnotations ne null) {
            writeBinaryAnnotationsValue(binaryAnnotations, _oprot)
            _root_.scala.Some(Span.BinaryAnnotationsField)
          } else {
            _root_.scala.None
          }
        case 9 =>
            writeDebugValue(debug, _oprot)
            _root_.scala.Some(Span.DebugField)
        case 10 =>
          if (timestamp.isDefined) {
            writeTimestampValue(timestamp.get, _oprot)
            _root_.scala.Some(Span.TimestampField)
          } else {
            _root_.scala.None
          }
        case 11 =>
          if (duration.isDefined) {
            writeDurationValue(duration.get, _oprot)
            _root_.scala.Some(Span.DurationField)
          } else {
            _root_.scala.None
          }
        case 12 =>
          if (traceIdHigh.isDefined) {
            writeTraceIdHighValue(traceIdHigh.get, _oprot)
            _root_.scala.Some(Span.TraceIdHighField)
          } else {
            _root_.scala.None
          }
        case _ => _root_.scala.None
      }
      if (_fieldOpt.isDefined) {
        _root_.scala.Some(TFieldBlob(_fieldOpt.get, Buf.ByteArray.Owned(_buff.getArray)))
      } else {
        _root_.scala.None
      }
    }
  }


  /**
   * Collects TCompactProtocol-encoded field values according to `getFieldBlob` into a map.
   */
  def getFieldBlobs(ids: TraversableOnce[Short]): immutable$Map[Short, TFieldBlob] =
    (ids.flatMap { id => getFieldBlob(id).map { fieldBlob => (id, fieldBlob) } }).toMap

  /**
   * Sets a field using a TCompactProtocol-encoded binary blob.  If the field is a known
   * field, the blob is decoded and the field is set to the decoded value.  If the field
   * is unknown and passthrough fields are enabled, then the blob will be stored in
   * _passthroughFields.
   */
  def setField(_blob: TFieldBlob): Span = {
    var traceId: Long = this.traceId
    var name: String = this.name
    var id: Long = this.id
    var parentId: _root_.scala.Option[Long] = this.parentId
    var annotations: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Annotation] = this.annotations
    var binaryAnnotations: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.BinaryAnnotation] = this.binaryAnnotations
    var debug: Boolean = this.debug
    var timestamp: _root_.scala.Option[Long] = this.timestamp
    var duration: _root_.scala.Option[Long] = this.duration
    var traceIdHigh: _root_.scala.Option[Long] = this.traceIdHigh
    var _passthroughFields = this._passthroughFields
    _blob.id match {
      case 1 =>
        traceId = readTraceIdValue(_blob.read)
      case 3 =>
        name = readNameValue(_blob.read)
      case 4 =>
        id = readIdValue(_blob.read)
      case 5 =>
        parentId = _root_.scala.Some(readParentIdValue(_blob.read))
      case 6 =>
        annotations = readAnnotationsValue(_blob.read)
      case 8 =>
        binaryAnnotations = readBinaryAnnotationsValue(_blob.read)
      case 9 =>
        debug = readDebugValue(_blob.read)
      case 10 =>
        timestamp = _root_.scala.Some(readTimestampValue(_blob.read))
      case 11 =>
        duration = _root_.scala.Some(readDurationValue(_blob.read))
      case 12 =>
        traceIdHigh = _root_.scala.Some(readTraceIdHighValue(_blob.read))
      case _ => _passthroughFields += _root_.scala.Tuple2(_blob.id, _blob)
    }
    new Immutable(
      traceId,
      name,
      id,
      parentId,
      annotations,
      binaryAnnotations,
      debug,
      timestamp,
      duration,
      traceIdHigh,
      _passthroughFields
    )
  }

  /**
   * If the specified field is optional, it is set to None.  Otherwise, if the field is
   * known, it is reverted to its default value; if the field is unknown, it is removed
   * from the passthroughFields map, if present.
   */
  def unsetField(_fieldId: Short): Span = {
    var traceId: Long = this.traceId
    var name: String = this.name
    var id: Long = this.id
    var parentId: _root_.scala.Option[Long] = this.parentId
    var annotations: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Annotation] = this.annotations
    var binaryAnnotations: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.BinaryAnnotation] = this.binaryAnnotations
    var debug: Boolean = this.debug
    var timestamp: _root_.scala.Option[Long] = this.timestamp
    var duration: _root_.scala.Option[Long] = this.duration
    var traceIdHigh: _root_.scala.Option[Long] = this.traceIdHigh

    _fieldId match {
      case 1 =>
        traceId = 0L
      case 3 =>
        name = null
      case 4 =>
        id = 0L
      case 5 =>
        parentId = _root_.scala.None
      case 6 =>
        annotations = _root_.scala.collection.immutable.Nil
      case 8 =>
        binaryAnnotations = _root_.scala.collection.immutable.Nil
      case 9 =>
        debug = false
      case 10 =>
        timestamp = _root_.scala.None
      case 11 =>
        duration = _root_.scala.None
      case 12 =>
        traceIdHigh = _root_.scala.None
      case _ =>
    }
    new Immutable(
      traceId,
      name,
      id,
      parentId,
      annotations,
      binaryAnnotations,
      debug,
      timestamp,
      duration,
      traceIdHigh,
      _passthroughFields - _fieldId
    )
  }

  /**
   * If the specified field is optional, it is set to None.  Otherwise, if the field is
   * known, it is reverted to its default value; if the field is unknown, it is removed
   * from the passthroughFields map, if present.
   */
  def unsetTraceId: Span = unsetField(1)

  def unsetName: Span = unsetField(3)

  def unsetId: Span = unsetField(4)

  def unsetParentId: Span = unsetField(5)

  def unsetAnnotations: Span = unsetField(6)

  def unsetBinaryAnnotations: Span = unsetField(8)

  def unsetDebug: Span = unsetField(9)

  def unsetTimestamp: Span = unsetField(10)

  def unsetDuration: Span = unsetField(11)

  def unsetTraceIdHigh: Span = unsetField(12)


  override def write(_oprot: TProtocol): Unit = {
    Span.validate(this)
    _oprot.writeStructBegin(Struct)
    writeTraceIdField(traceId, _oprot)
    if (name ne null) writeNameField(name, _oprot)
    writeIdField(id, _oprot)
    if (parentId.isDefined) writeParentIdField(parentId.get, _oprot)
    if (annotations ne null) writeAnnotationsField(annotations, _oprot)
    if (binaryAnnotations ne null) writeBinaryAnnotationsField(binaryAnnotations, _oprot)
    writeDebugField(debug, _oprot)
    if (timestamp.isDefined) writeTimestampField(timestamp.get, _oprot)
    if (duration.isDefined) writeDurationField(duration.get, _oprot)
    if (traceIdHigh.isDefined) writeTraceIdHighField(traceIdHigh.get, _oprot)
    if (_passthroughFields.nonEmpty) {
      _passthroughFields.values.foreach { _.write(_oprot) }
    }
    _oprot.writeFieldStop()
    _oprot.writeStructEnd()
  }

  def copy(
    traceId: Long = this.traceId,
    name: String = this.name,
    id: Long = this.id,
    parentId: _root_.scala.Option[Long] = this.parentId,
    annotations: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Annotation] = this.annotations,
    binaryAnnotations: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.BinaryAnnotation] = this.binaryAnnotations,
    debug: Boolean = this.debug,
    timestamp: _root_.scala.Option[Long] = this.timestamp,
    duration: _root_.scala.Option[Long] = this.duration,
    traceIdHigh: _root_.scala.Option[Long] = this.traceIdHigh,
    _passthroughFields: immutable$Map[Short, TFieldBlob] = this._passthroughFields
  ): Span =
    new Immutable(
      traceId,
      name,
      id,
      parentId,
      annotations,
      binaryAnnotations,
      debug,
      timestamp,
      duration,
      traceIdHigh,
      _passthroughFields
    )

  override def canEqual(other: Any): Boolean = other.isInstanceOf[Span]

  private[this] def _equals(other: Span): Boolean =
      this.productArity == other.productArity &&
      this.productIterator.sameElements(other.productIterator) &&
      this._passthroughFields == other._passthroughFields

  override def equals(other: Any): Boolean =
    canEqual(other) && _equals(other.asInstanceOf[Span])

  override def hashCode: Int = {
    _root_.scala.runtime.ScalaRunTime._hashCode(this)
  }

  override def toString: String = _root_.scala.runtime.ScalaRunTime._toString(this)

  override def productPrefix: String = "Span"

  def _codec: ValidatingThriftStructCodec3[Span] = Span

  def newBuilder(): StructBuilder[Span] = new SpanStructBuilder(_root_.scala.Some(this), fieldTypes)
}

private[thriftscala] class SpanStructBuilder(instance: _root_.scala.Option[Span], fieldTypes: IndexedSeq[ClassTag[_]])
    extends StructBuilder[Span](fieldTypes) {

  def build(): Span = {
    val _fieldArray = fieldArray // shadow variable
    if (instance.isDefined) {
      val instanceValue = instance.get
      Span(
        if (_fieldArray(0) == null) instanceValue.traceId else _fieldArray(0).asInstanceOf[Long],
        if (_fieldArray(1) == null) instanceValue.name else _fieldArray(1).asInstanceOf[String],
        if (_fieldArray(2) == null) instanceValue.id else _fieldArray(2).asInstanceOf[Long],
        if (_fieldArray(3) == null) instanceValue.parentId else _fieldArray(3).asInstanceOf[_root_.scala.Option[Long]],
        if (_fieldArray(4) == null) instanceValue.annotations else _fieldArray(4).asInstanceOf[_root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Annotation]],
        if (_fieldArray(5) == null) instanceValue.binaryAnnotations else _fieldArray(5).asInstanceOf[_root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.BinaryAnnotation]],
        if (_fieldArray(6) == null) instanceValue.debug else _fieldArray(6).asInstanceOf[Boolean],
        if (_fieldArray(7) == null) instanceValue.timestamp else _fieldArray(7).asInstanceOf[_root_.scala.Option[Long]],
        if (_fieldArray(8) == null) instanceValue.duration else _fieldArray(8).asInstanceOf[_root_.scala.Option[Long]],
        if (_fieldArray(9) == null) instanceValue.traceIdHigh else _fieldArray(9).asInstanceOf[_root_.scala.Option[Long]]
      )
    } else {
      if (genericArrayOps(_fieldArray).contains(null)) throw new InvalidFieldsException(structBuildError("Span"))
      Span(
        _fieldArray(0).asInstanceOf[Long],
        _fieldArray(1).asInstanceOf[String],
        _fieldArray(2).asInstanceOf[Long],
        _fieldArray(3).asInstanceOf[_root_.scala.Option[Long]],
        _fieldArray(4).asInstanceOf[_root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Annotation]],
        _fieldArray(5).asInstanceOf[_root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.BinaryAnnotation]],
        _fieldArray(6).asInstanceOf[Boolean],
        _fieldArray(7).asInstanceOf[_root_.scala.Option[Long]],
        _fieldArray(8).asInstanceOf[_root_.scala.Option[Long]],
        _fieldArray(9).asInstanceOf[_root_.scala.Option[Long]]
      )
    }
  }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy