예제 #1
0
        public ActionResult <MeasurementInfo> GetMeasurement(string appName, string key)
        {
            if (string.Compare(key, statsKey) != 0)
            {
                return(BadRequest());
            }
            var ret = new MeasurementInfo();
            var app = ParseApp(appName);

            if (app == null)
            {
                return(NotFound());
            }
            var measurement = measurementService.GetMeasurement(app.Value);

            if (measurement == null)
            {
                return(NotFound());
            }
            var active = measurement.GetActiveOperations();
            var error  = measurement.GetErrorOperations();

            ret.Successed         = measurement.SuccessedOperations;
            ret.Failed            = measurement.FailedOperations;
            ret.ActiveOperations  = ToOperationInfos(active);
            ret.ErrorOperations   = ToOperationInfos(error);
            ret.ProlongOperations = ToOperationInfos(measurement.GetProlongOperations());
            ret.LastOperation     = OperationInfo.From(measurement.LastOperation);
            ret.Counters          = new Dictionary <string, int>();

            foreach (var kind in measurement.GetOperationKinds())
            {
                ret.Counters[kind.ToString()] = kind.Counter;
            }


            return(new ActionResult <MeasurementInfo>(ret));
        }