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); }
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, Encoding.UTF8.GetString(binaryAnnotation.Value)); writer.Write(comma); writer.WriteAnchor(endpoint); SerializeEndPoint(writer, endPoint, serviceName); writer.Write(closingBrace); }
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); }
/// <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 }); }
private bool TryGetLocalComponent(out BinaryAnnotation localComponentBinAnnotation) { localComponentBinAnnotation = BinaryAnnotations.FirstOrDefault(a => a.Key.Equals(zipkinCoreConstants.LOCAL_COMPONENT)); return(localComponentBinAnnotation != default(BinaryAnnotation)); }
public void AddBinaryAnnotation(BinaryAnnotation binaryAnnotation) { BinaryAnnotations.Add(binaryAnnotation); }