Ejemplo n.º 1
0
        private List <MetricValue> readMetricValuesIntoEntity(WEBEntityBase entity, JobTarget jobTarget, string metricName, AppDRESTMetric appDRESTMetric, int timerangeDuration)
        {
            List <MetricValue> metricValues = new List <MetricValue>(appDRESTMetric.metricValues.Count);

            foreach (AppDRESTMetricValue appDRESTMetricValue in appDRESTMetric.metricValues)
            {
                // Populate metrics into the list for output into CSV
                MetricValue metricValue = new MetricValue();

                metricValue.Controller      = jobTarget.Controller;
                metricValue.ApplicationID   = jobTarget.ApplicationID;
                metricValue.ApplicationName = jobTarget.Application;

                if (entity != null)
                {
                    if (entity is WEBApplication)
                    {
                        WEBApplication webApplication = (WEBApplication)entity;

                        metricValue.EntityID   = webApplication.ApplicationID;
                        metricValue.EntityName = webApplication.ApplicationName;
                        metricValue.EntityType = WEBApplication.ENTITY_TYPE;
                    }
                    else if (entity is WEBPage)
                    {
                        WEBPage webPage = (WEBPage)entity;

                        metricValue.EntityID   = webPage.PageID;
                        metricValue.EntityName = webPage.PageName;
                        metricValue.EntityType = webPage.PageType;
                    }
                }

                metricValue.EventTimeStampUtc = UnixTimeHelper.ConvertFromUnixTimestamp(appDRESTMetricValue.startTimeInMillis);
                metricValue.EventTimeStamp    = metricValue.EventTimeStampUtc.ToLocalTime();
                metricValue.EventTime         = metricValue.EventTimeStamp;

                metricValue.MetricName = metricName;
                metricValue.MetricID   = appDRESTMetric.metricId;
                switch (appDRESTMetric.frequency)
                {
                case "SIXTY_MIN":
                {
                    metricValue.MetricResolution = 60;
                    break;
                }

                case "TEN_MIN":
                {
                    metricValue.MetricResolution = 10;
                    break;
                }

                case "ONE_MIN":
                {
                    metricValue.MetricResolution = 1;
                    break;
                }

                default:
                {
                    metricValue.MetricResolution = 1;
                    break;
                }
                }

                metricValue.Count       = appDRESTMetricValue.count;
                metricValue.Min         = appDRESTMetricValue.min;
                metricValue.Max         = appDRESTMetricValue.max;
                metricValue.Occurrences = appDRESTMetricValue.occurrences;
                metricValue.Sum         = appDRESTMetricValue.sum;
                metricValue.Value       = appDRESTMetricValue.value;

                metricValues.Add(metricValue);
            }

            return(metricValues);
        }
Ejemplo n.º 2
0
        private List <MetricValue> readMetricsIntoEntities(
            List <AppDRESTMetric> metricData,
            Dictionary <string, WEBEntityBase> entitiesDictionaryByName,
            JobTarget jobTarget,
            JobTimeRange jobTimeRange)
        {
            WEBEntityBase entity = null;

            int timerangeDuration = (int)(jobTimeRange.To - jobTimeRange.From).Duration().TotalMinutes;

            List <MetricValue> metricValues = new List <MetricValue>(metricData.Count * timerangeDuration);

            foreach (AppDRESTMetric appDRESTMetric in metricData)
            {
                if (appDRESTMetric.metricValues.Count == 0)
                {
                    // No metrics in this chunk
                    continue;
                }

                #region Get metric path components and metric name

                // Analyze metric path returned by the call to controller
                string[] metricPathComponents = appDRESTMetric.metricPath.Split('|');

                if (metricPathComponents.Length == 0)
                {
                    // Metric name was no good
                    logger.Warn("Metric path='{0}' could not be parsed into individual components", appDRESTMetric.metricPath);
                    continue;
                }

                string[] metricNameComponents = appDRESTMetric.metricName.Split('|');

                if (metricNameComponents.Length == 0)
                {
                    // Metric name was no good
                    logger.Warn("Metric name='{0}' could not be parsed into individual components", appDRESTMetric.metricName);
                    continue;
                }

                // Name of the metric is always the last one in the metric path
                string metricName = metricPathComponents[metricPathComponents.Length - 1];

                #endregion

                #region Determine metric entity type, scope and name from metric path

                switch (metricPathComponents[1])
                {
                case "App":

                    #region Application level

                    // MetricPath = End User Experience|App|Requests per Minute
                    // MetricName = EUM|App|Page Requests per Minute

                    entity = entitiesDictionaryByName.FirstOrDefault().Value;

                    #endregion

                    break;

                case "Base Pages":

                    #region Web Pages

                    // MetricPath = End User Experience|Base Pages|dev-movietix.demo.appdynamics.com/login.aspx|Requests per Minute
                    // MetricName = BTM|Application Diagnostic Data|Base Page:976|Requests per Minute

                    entitiesDictionaryByName.TryGetValue(metricPathComponents[2], out entity);

                    #endregion

                    break;

                case "AJAX Requests":

                    #region AJAX Requests

                    // MetricPath = End User Experience|AJAX Requests|dev-movietix.demo.appdynamics.com/api/search|Requests per Minute
                    // MetricName = BTM|Application Diagnostic Data|AJAX Request:2310|Requests per Minute

                    entitiesDictionaryByName.TryGetValue(metricPathComponents[2], out entity);

                    #endregion

                    break;

                case "Virtual Pages":

                    #region IFrame

                    //"metricName" : "BTM|Application Diagnostic Data|Virtual Page:4762|Requests per Minute",
                    //"metricPath" : "End User Experience|Virtual Pages|Login|Requests per Minute",

                    entitiesDictionaryByName.TryGetValue(metricPathComponents[2], out entity);

                    #endregion

                    break;

                case "IFrames":

                    #region IFrame

                    // No examples I've seen have these

                    entitiesDictionaryByName.TryGetValue(metricPathComponents[2], out entity);

                    #endregion

                    break;

                default:
                    // Unsupported type of metric
                    logger.Warn("Metric path='{0}' is not of supported type of metric for processing", appDRESTMetric.metricPath);

                    break;
                }

                #endregion

                List <MetricValue> metricValuesConverted = readMetricValuesIntoEntity(entity, jobTarget, metricName, appDRESTMetric, timerangeDuration);
                metricValues.AddRange(metricValuesConverted);
            }

            return(metricValues);
        }