private void Init() { if (_inited) { return; } // 自动从本地星尘代理获取地址 if (Client == null) { try { var client = new LocalStarClient(); var inf = client.GetInfo(); if (!inf.Server.IsNullOrEmpty()) { Client = new ApiHttpClient(inf.Server); } } catch { } } var server = Client is ApiHttpClient http?http.Services.Join(",", e => e.Address) : (Client + ""); WriteLog("StarTracer.Start AppId={0} ClientId={1} Server={2}", AppId, ClientId, server); _inited = true; }
public void Info() { var client = new LocalStarClient(); var inf = client.GetInfo(); Assert.NotNull(inf); Assert.NotEmpty(inf.Server); }
/// <summary>全局注册星尘性能追踪器</summary> /// <param name="server">星尘监控中心地址,为空时自动从本地探测</param> /// <returns></returns> public static StarTracer Register(String server = null) { if (server.IsNullOrEmpty()) { var set = Setting.Current; server = set.Server; } if (server.IsNullOrEmpty()) { var local = new LocalStarClient(); var inf = local.GetInfo(); server = inf?.Server; if (!server.IsNullOrEmpty()) { XTrace.WriteLine("星尘探测:{0}", server); } } if (server.IsNullOrEmpty()) { return(null); } if (Instance is StarTracer tracer && tracer.Client is ApiHttpClient) { return(tracer); } tracer = new StarTracer(server) { Log = XTrace.Log }; tracer.AttachGlobal(); return(tracer); }