Ejemplo n.º 1
0
            private void RaiseMetricsPerFunctionEvent()
            {
                List <FunctionMetrics> metricsEventsList = GetMetricsQueueSnapshot();

                var aggregatedEventsPerFunction = from item in metricsEventsList
                                                  group item by item.FunctionName into FunctionGroups
                                                  select new
                {
                    FunctionName          = FunctionGroups.Key,
                    StartedCount          = Convert.ToUInt64(FunctionGroups.Count(x => x.ExecutionStage == ExecutionStage.Started)),
                    FailedCount           = Convert.ToUInt64(FunctionGroups.Count(x => x.ExecutionStage == ExecutionStage.Failed)),
                    SucceededCount        = Convert.ToUInt64(FunctionGroups.Count(x => x.ExecutionStage == ExecutionStage.Succeeded)),
                    TotalExectionTimeInMs = Convert.ToUInt64(FunctionGroups.Sum(x => Convert.ToDecimal(x.ExecutionTimeInMS)))
                };

                foreach (var functionEvent in aggregatedEventsPerFunction)
                {
                    MetricsEventGenerator.LogFunctionExecutionAggregateEvent(appName, functionEvent.FunctionName, (long)functionEvent.TotalExectionTimeInMs, (long)functionEvent.StartedCount, (long)functionEvent.SucceededCount, (long)functionEvent.FailedCount);
                }
            }
Ejemplo n.º 2
0
        protected override void Serialize(IDictionary <string, object> json)
        {
            if (FunctionData.HasValue())
            {
                json.Add("data", FunctionData);
            }
            else
            {
                FluentDictionary.For(json).Add("data", Data, string.Empty);
            }

            if (FunctionTotal.HasValue())
            {
                json.Add("total", FunctionTotal);
            }
            else
            {
                FluentDictionary.For(json).Add("total", Total, string.Empty);
            }

            if (FunctionErrors.HasValue())
            {
                json.Add("errors", FunctionErrors);
            }
            else
            {
                FluentDictionary.For(json).Add("errors", Errors, string.Empty);
            }

            if (FunctionAggregates.HasValue())
            {
                json.Add("aggregates", FunctionAggregates);
            }
            else
            {
                FluentDictionary.For(json).Add("aggregates", Aggregates, string.Empty);
            }

            if (FunctionGroups.HasValue())
            {
                json.Add("groups", FunctionGroups);
            }
            else
            {
                FluentDictionary.For(json).Add("groups", Groups, string.Empty);
            }

            if (Model != null)
            {
                json.Add("model", Model.ToJson());
            }

            if (!string.IsNullOrEmpty(Type))
            {
                json.Add("type", Type);
            }

            if (Parse.HasValue())
            {
                json.Add("parse", Parse);
            }
        }