Пример #1
0
        /// <summary>全局注册星尘性能跟踪器</summary>
        /// <param name="server">星尘监控中心地址</param>
        /// <returns></returns>
        public static StarTracer Register(String server)
        {
            if (server.IsNullOrEmpty())
            {
                return(null);
            }

            if (Instance is StarTracer tracer && tracer.Client is ApiHttpClient)
            {
                return(tracer);
            }

            tracer = new StarTracer(server)
            {
                Log = XTrace.Log
            };
            DefaultTracer.Instance = tracer;

            return(tracer);
        }
Пример #2
0
        /// <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);
        }