/// <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); }; }
/// <summary> /// 创建一个服务跟踪 /// </summary> /// <param name="serviceName">对应服务的名称</param> /// <param name="port">端口号</param> public ServerTrace(string serviceName, int port) { this.Trace = Unity.Get(); this.RecordEvent += () => { this.Trace.Record(Annotations.ServerRecv(), this._beginDate); this.Trace.Record(Annotations.ServiceName(serviceName), this._beginDate); this.Trace.Record(Annotations.ServerAddr(serviceName, new IPEndPoint(SerializerUtils.DefaultEndPoint.Address, port)), this._beginDate); }; }
/// <summary> /// 通过<paramref name="dic"/>构建本地跟踪通过<see cref="ServerTrace"/>,<see cref="LocalTrace"/>使用 /// </summary> /// <param name="dic">字典对象</param> public void Create(IDictionary <string, string> dic = null) { if (dic == null) { Unity.Get(); } else { tracing.Trace trace; if (!_extractor.TryExtract(dic, (c, key) => { string value; c.TryGetValue(key, out value); return(value); }, out trace)) { Unity.Get(); } else { Unity.Set(trace); } } }
/// <summary> /// /// </summary> protected override void ForceSampled() { Unity.Get().ForceSampled(); base.ForceSampled(); }