Пример #1
0
        void Write(JsonWriter writer, Span span)
        {
            writer.WriteStartObject();
            writer.WritePropertyName("traceId");
            writer.WriteValue(span.Context.TraceId.ToString());
            writer.WritePropertyName("name");
            writer.WriteValue(span.Name);
            writer.WritePropertyName("id");
            writer.WriteValue(span.Context.SpanId.ToString("x16"));
            //set parent id if specified
            writer.WritePropertyName("parentId");
            writer.WriteValue(span.Context.ParentId?.ToString("x16"));

            //set span id if specified
            Write(writer, span.Kind);
            writer.WritePropertyName("timestamp");
            writer.WriteValue(ZipkinUtil.UnixStartMs(span));
            writer.WritePropertyName("duration");
            writer.WriteValue(ZipkinUtil.DurationMs(span));
            writer.WritePropertyName("debug");
            writer.WriteValue(span.Context.Debug);
            writer.WritePropertyName("shared");
            writer.WriteValue(span.Context.Shared);
            //remote endpoint obj
            Write(writer, "localEndpoint", span.LocalEndpoint);
            Write(writer, "remoteEndpoint", span.RemoteEndpoint);
            Write(writer, span.Annotations);
            Write(writer, span.Tags);

            writer.WriteEndObject();
        }
Пример #2
0
 void Write(JsonWriter writer, IReadOnlyList <Annotation> annotations)
 {
     writer.WritePropertyName("annotations");
     writer.WriteStartArray();
     if (annotations.Count > 0)
     {
         foreach (var annotation in annotations)
         {
             writer.WriteStartObject();
             writer.WritePropertyName("timestamp");
             writer.WriteValue(ZipkinUtil.ToUnixMs(annotation.TimeStamp));
             writer.WritePropertyName("value");
             writer.WriteValue(annotation.Value);
             writer.WriteEndObject();
         }
     }
     writer.WriteEndArray();
 }