コード例 #1
0
ファイル: TraceController.cs プロジェクト: wenfeifei/Stardust
        public TraceResponse Report([FromBody] TraceModel model, String token)
        {
            var builders = model?.Builders.Cast <ISpanBuilder>().ToArray();

            //var builders = new ISpanBuilder[0];
            if (model == null || model.AppId.IsNullOrEmpty() || builders == null || builders.Length == 0)
            {
                return(null);
            }

            var ip = HttpContext.GetUserHost();

            if (ip.IsNullOrEmpty())
            {
                ip = ManageProvider.UserHost;
            }

            var set = Setting.Current;

            // 新版验证方式,访问令牌
            Data.App ap = null;
            if (!token.IsNullOrEmpty() && token.Split(".").Length == 3)
            {
                ap = _service.DecodeToken(token, set);
                if (ap == null || ap.Name != model.AppId)
                {
                    throw new InvalidOperationException($"授权不匹配[{model.AppId}]!=[{ap.Name}]!");
                }
            }
            Data.App.UpdateInfo(model, ip);

            // 该应用的跟踪配置信息
            var app = AppTracer.FindByName(model.AppId);

            if (app == null)
            {
                app = new AppTracer
                {
                    Name        = model.AppId,
                    DisplayName = model.AppName,
                    Enable      = set.AutoRegister,
                };
                app.Save();
            }

            // 校验应用
            if (app == null || !app.Enable)
            {
                throw new Exception($"无效应用[{model.AppId}/{model.AppName}]");
            }

            // 插入数据
            Task.Run(() => ProcessData(app, model, ip, builders));

            // 构造响应
            var rs = new TraceResponse
            {
                Period     = app.Period,
                MaxSamples = app.MaxSamples,
                MaxErrors  = app.MaxErrors,
                Timeout    = app.Timeout,
                //Excludes = app.Excludes?.Split(",", ";"),
            };

            // 新版本才返回Excludes,老版本客户端在处理Excludes时有BUG,错误处理/
            if (!model.Version.IsNullOrEmpty())
            {
                rs.Excludes = app.Excludes?.Split(",", ";");
            }

            return(rs);
        }
 public static void Main() {
     Data.App app = new Data.App();
     app.InitializeComponent();
     app.Run();
 }
コード例 #3
0
ファイル: App.g.i.cs プロジェクト: jobyjames85/Framework
 public static void Main()
 {
     Data.App app = new Data.App();
     app.InitializeComponent();
     app.Run();
 }