Beispiel #1
0
        public void ThriftConversionLocalComponentWithHostAndEmptyServiceName()
        {
            var binAnn       = new BinaryAnnotation(zipkinCoreConstants.LOCAL_COMPONENT, Encoding.ASCII.GetBytes("hello"), AnnotationType.STRING, TimeUtils.UtcNow, null, null);
            var thriftBinAnn = ThriftSpanSerializer.ConvertToThrift(binAnn, _someHost);

            AssertEndpointIsCorrect(thriftBinAnn.Host);
        }
Beispiel #2
0
 private static void SerializeBinaryAnnotation(StreamWriter writer, BinaryAnnotation binaryAnnotation, IPEndPoint endPoint, string serviceName)
 {
     writer.Write(openingBrace);
     writer.WriteField(key, binaryAnnotation.Key);
     writer.Write(comma);
     writer.WriteField(value, SerializerUtils.ToEscaped(Encoding.UTF8.GetString(binaryAnnotation.Value)));
     writer.Write(comma);
     writer.WriteAnchor(endpoint);
     SerializeEndPoint(writer, endPoint, serviceName);
     writer.Write(closingBrace);
 }
Beispiel #3
0
        private void AssertBinaryAnnotationConversion(string serviceName, IPEndPoint endpoint, Endpoint expectedEndpoint)
        {
            const string         key  = "myKey";
            var                  data = Encoding.ASCII.GetBytes("hello");
            const AnnotationType type = AnnotationType.STRING;

            var binAnn = new BinaryAnnotation(key, data, type, TimeUtils.UtcNow, serviceName, endpoint);

            var thriftBinAnn = ThriftSpanSerializer.ConvertToThrift(binAnn, _someHost);

            Assert.AreEqual(key, thriftBinAnn.Key);
            Assert.AreEqual(data, thriftBinAnn.Value);
            Assert.AreEqual(type, thriftBinAnn.Annotation_type);
            AssertEndpointIsEqual(expectedEndpoint, thriftBinAnn.Host);
        }
Beispiel #4
0
        /// <summary>
        /// Convert this span binary annotation object to its Thrift equivalent.
        /// </summary>
        /// <returns></returns>
        public static Thrift.BinaryAnnotation ConvertToThrift(BinaryAnnotation binaryAnnotation, Thrift.Endpoint spanEndpoint)
        {
            var host     = spanEndpoint;
            var endpoint = binaryAnnotation.Host;

            if (endpoint != null)
            {
                host = ConvertToThrift(endpoint.IPEndPoint, endpoint.ServiceName ?? spanEndpoint.Service_name);
            }
            return(new Thrift.BinaryAnnotation
            {
                Annotation_type = binaryAnnotation.AnnotationType,
                Key = binaryAnnotation.Key,
                Value = binaryAnnotation.Value,
                Host = host
            });
        }
Beispiel #5
0
 private bool TryGetLocalComponent(out BinaryAnnotation localComponentBinAnnotation)
 {
     localComponentBinAnnotation = BinaryAnnotations.FirstOrDefault(a => a.Key.Equals(zipkinCoreConstants.LOCAL_COMPONENT));
     return(localComponentBinAnnotation != default(BinaryAnnotation));
 }
Beispiel #6
0
 public void AddBinaryAnnotation(BinaryAnnotation binaryAnnotation)
 {
     BinaryAnnotations.Add(binaryAnnotation);
 }
Beispiel #7
0
 public BinaryAnnotation(zipkin4net.Tracers.Zipkin.BinaryAnnotation binaryAnnotation, IPEndPoint endpoint, string serviceName)
 {
     this.binaryAnnotation = binaryAnnotation;
     this.endpoint         = endpoint;
     this.serviceName      = serviceName;
 }