Ejemplo n.º 1
0
        public static void Write(Span span, ThriftProtocol oprot)
        {
            oprot.IncrementRecursionDepth();
            try
            {
                var struc = new TStruct(/*"Span"*/);
                oprot.WriteStructBegin(struc);
                var field = new TField();
                if (span.TraceId != 0L)
                {
//					field.Name = "trace_id";
                    field.Type = TType.I64;
                    field.ID   = 1;
                    oprot.WriteFieldBegin(field);
                    oprot.WriteI64(span.TraceId);
                    oprot.WriteFieldEnd();
                }
                if (span.Name != null)
                {
//					field.Name = "name";
                    field.Type = TType.String;
                    field.ID   = 3;
                    oprot.WriteFieldBegin(field);
                    oprot.WriteString(span.Name);
                    oprot.WriteFieldEnd();
                }
                if (span.Id != 0)
                {
//					field.Name = "id";
                    field.Type = TType.I64;
                    field.ID   = 4;
                    oprot.WriteFieldBegin(field);
                    oprot.WriteI64(span.Id);
                    oprot.WriteFieldEnd();
                }
                if (span.ParentId.HasValue)
                {
//					field.Name = "parent_id";
                    field.Type = TType.I64;
                    field.ID   = 5;
                    oprot.WriteFieldBegin(field);
                    oprot.WriteI64(span.ParentId.Value);
                    oprot.WriteFieldEnd();
                }
                if (span.Annotations != null && span.Annotations.Count != 0)
                {
//					field.Name = "annotations";
                    field.Type = TType.List;
                    field.ID   = 6;
                    oprot.WriteFieldBegin(field);
                    {
                        oprot.WriteListBegin(new TList(TType.Struct, span.Annotations.Count));
                        foreach (var annotation in span.Annotations)
                        {
                            AnnotationSerializer.Write(annotation, oprot);
                        }
                        oprot.WriteListEnd();
                    }
                    oprot.WriteFieldEnd();
                }
                if (span.BinaryAnnotations != null && span.BinaryAnnotations.Count != 0)
                {
//					field.Name = "binary_annotations";
                    field.Type = TType.List;
                    field.ID   = 8;
                    oprot.WriteFieldBegin(field);
                    {
                        oprot.WriteListBegin(new TList(TType.Struct, span.BinaryAnnotations.Count));
                        foreach (BinaryAnnotation annotation in span.BinaryAnnotations)
                        {
                            BinaryAnnotationSerializer.Write(annotation, oprot);
                            // _iter7.Write(oprot);
                        }
                        oprot.WriteListEnd();
                    }
                    oprot.WriteFieldEnd();
                }
                if (span.IsDebug)
                {
//					field.Name = "debug";
                    field.Type = TType.Bool;
                    field.ID   = 9;
                    oprot.WriteFieldBegin(field);
                    oprot.WriteBool(span.IsDebug);
                    oprot.WriteFieldEnd();
                }
                if (span.Timestamp != null)
                {
//					field.Name = "timestamp";
                    field.Type = TType.I64;
                    field.ID   = 10;
                    oprot.WriteFieldBegin(field);
                    oprot.WriteI64(span.Timestamp.Value.ToNixTimeMicro());
                    oprot.WriteFieldEnd();
                }
                if (span.DurationInMicroseconds.HasValue)
                {
//					field.Name = "duration";
                    field.Type = TType.I64;
                    field.ID   = 11;
                    oprot.WriteFieldBegin(field);
                    oprot.WriteI64(span.DurationInMicroseconds.Value);
                    oprot.WriteFieldEnd();
                }
                oprot.WriteFieldStop();
                oprot.WriteStructEnd();
            }
            finally
            {
                oprot.DecrementRecursionDepth();
            }
        }