/// <summary> /// 创建一个客户端监控 /// </summary> /// <param name="serviceName">服务名称</param> /// <param name="operation">操作</param> public ClientTrace(string serviceName, string operation) { this.Trace = Unity.Get().Child(); this.RecordEvent += () => { this.Trace.Record(Annotations.ClientSend(), this._beginDate); this.Trace.Record(Annotations.ServiceName(serviceName), this._beginDate); this.Trace.Record(Annotations.Rpc(operation), this._beginDate); this.Trace.Record(Annotations.ClientAddr(SerializerUtils.DefaultEndPoint), this._beginDate); }; }
public void ToStringWriteExtraDataInAdditionToType() { Assert.AreEqual("TagAnnotation: sampleTagKey:sampleTagValue", Annotations.Tag("sampleTagKey", "sampleTagValue").ToString()); Assert.AreEqual("Rpc: GET", Annotations.Rpc("GET").ToString()); Assert.AreEqual("ServiceName: sampleName", Annotations.ServiceName("sampleName").ToString()); Assert.AreEqual("Event: sampleName", Annotations.Event("sampleName").ToString()); Assert.AreEqual("LocalOperationStart: sampleName", Annotations.LocalOperationStart("sampleName").ToString()); var samIpEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 80); Assert.AreEqual("ClientAddr: 127.0.0.1:80", Annotations.ClientAddr(samIpEndPoint).ToString()); Assert.AreEqual("ServerAddr: sampleName/127.0.0.1:80", Annotations.ServerAddr("sampleName", samIpEndPoint).ToString()); Assert.AreEqual("MessageAddr: sampleName/127.0.0.1:80", Annotations.MessageAddr("sampleName", samIpEndPoint).ToString()); }
public void FactoryReturnsCorrectTypes() { Assert.IsInstanceOf <TagAnnotation>(Annotations.Tag("", "")); Assert.IsInstanceOf <ClientRecv>(Annotations.ClientRecv()); Assert.IsInstanceOf <ClientSend>(Annotations.ClientSend()); Assert.IsInstanceOf <LocalAddr>(Annotations.LocalAddr(null)); Assert.IsInstanceOf <Rpc>(Annotations.Rpc("")); Assert.IsInstanceOf <ServerRecv>(Annotations.ServerRecv()); Assert.IsInstanceOf <ServerSend>(Annotations.ServerSend()); Assert.IsInstanceOf <ServiceName>(Annotations.ServiceName("")); Assert.IsInstanceOf <Event>(Annotations.Event("")); Assert.IsInstanceOf <ClientAddr>(Annotations.ClientAddr(null)); Assert.IsInstanceOf <ServerAddr>(Annotations.ServerAddr(null, null)); }
public void FactoryReturnsCorrectTypes() { Assert.IsInstanceOf <TagAnnotation>(Annotations.Tag("", "")); Assert.IsInstanceOf <ClientRecv>(Annotations.ClientRecv()); Assert.IsInstanceOf <ClientSend>(Annotations.ClientSend()); Assert.IsInstanceOf <LocalAddr>(Annotations.LocalAddr(null)); Assert.IsInstanceOf <Rpc>(Annotations.Rpc("")); Assert.IsInstanceOf <ServerRecv>(Annotations.ServerRecv()); Assert.IsInstanceOf <ServerSend>(Annotations.ServerSend()); Assert.IsInstanceOf <ServiceName>(Annotations.ServiceName("")); Assert.IsInstanceOf <Event>(Annotations.Event("")); Assert.IsInstanceOf <ClientAddr>(Annotations.ClientAddr(null)); Assert.IsInstanceOf <ServerAddr>(Annotations.ServerAddr(null, null)); Assert.IsInstanceOf <MessageAddr>(Annotations.MessageAddr(null, null)); Assert.IsInstanceOf <ConsumerStart>(Annotations.ConsumerStart()); Assert.IsInstanceOf <ConsumerStop>(Annotations.ConsumerStop()); Assert.IsInstanceOf <ProducerStart>(Annotations.ProducerStart()); Assert.IsInstanceOf <ProducerStop>(Annotations.ProducerStop()); Assert.IsInstanceOf <LocalOperationStart>(Annotations.LocalOperationStart("")); Assert.IsInstanceOf <LocalOperationStop>(Annotations.LocalOperationStop()); }