public HealthMonitor(DiagnosticsConfig config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            ClientIP       = EdgeServerDataClient.IpNA;
            EdgeServer     = EdgeServerDataClient.IpNA;
            VideoSessionId = Guid.NewGuid();

            Configuration = config;

            agent = new SamplingAgent();
            if (config.TrackQuality)
            {
                agent.Agents.Add(new QualityAggregationAgent(config.AggregationInterval, config.QualityConfig));
            }
            if (config.TrackQualitySnapshot)
            {
                agent.Agents.Add(new QualitySnapshotAgent(config.SnapshotInterval, config.QualityConfig));
            }
            if (config.TrackDownloadErrors)
            {
                agent.Agents.Add(new DownloadErrorSampleAgent(Configuration));
            }

            if (Configuration.InitTraceMonitor)
            {
                TraceMonitor.Init(Configuration.TracingConfig);
            }
        }
        public HealthMonitor(DiagnosticsConfig config)
        {
            if (config == null)
                throw new ArgumentNullException("config");

            ClientIP = EdgeServerDataClient.IpNA;
            EdgeServer = EdgeServerDataClient.IpNA;
            VideoSessionId = Guid.NewGuid();

            Configuration = config;

            agent = new SamplingAgent();
            if (config.TrackQuality)
                agent.Agents.Add(new QualityAggregationAgent(config.AggregationInterval, config.QualityConfig));
            if (config.TrackQualitySnapshot)
                agent.Agents.Add(new QualitySnapshotAgent(config.SnapshotInterval, config.QualityConfig));
            if (config.TrackDownloadErrors)
                agent.Agents.Add(new DownloadErrorSampleAgent(Configuration));

            if (Configuration.InitTraceMonitor)
            {
                TraceMonitor.Init(Configuration.TracingConfig);
            }
        }
 public SMFLogger(DiagnosticsConfig diagConfig, LoggingConfig loggingConfig)
 {
     DiagConfig = diagConfig;
     healthMonitorLogger = new HealthMonitorLogger(loggingConfig);
 }
 public DownloadErrorSampleAgent(DiagnosticsConfig Settings)
     : base(false, Settings.AggregationInterval)
 { }
 public DownloadErrorSampleAgent(DiagnosticsConfig Settings)
     : base(false, Settings.AggregationInterval)
 {
 }
        /// <summary>
        /// Creates an instance of the main diagnostic config object from an XmlReader
        /// </summary>
        public static DiagnosticsConfig Load(XmlReader reader)
        {
            if (reader == null)
                throw new ArgumentNullException("reader");

            var result = new DiagnosticsConfig();
            List<EdgeServerRules> edgeServerRuleCollection = null;

            reader.GoToElement();
            reader.ReadStartElement();
            if (!reader.IsEmptyElement)
            {
                while (reader.GoToSibling())
                {
                    switch (reader.LocalName)
                    {
                        case "TraceMonitor":
                            result.TracingConfig = TracingConfig.Load(reader);
                            break;

                        case "EdgeServerRules":
                            if (!reader.IsEmptyElement)
                            {
                                if (edgeServerRuleCollection == null)
                                {
                                    edgeServerRuleCollection = new List<EdgeServerRules>();
                                    result.EdgeServerRuleCollection = edgeServerRuleCollection;
                                }
                                edgeServerRuleCollection.Add(EdgeServerRules.Load(reader));
                            }
                            else
                                reader.Skip();
                            break;

                        case "Diagnostics":
                            if (!reader.IsEmptyElement)
                            {
                                reader.ReadStartElement();
                                while (reader.GoToSibling())
                                {
                                    switch (reader.LocalName)
                                    {
                                        case "TrackQuality":
                                            result.TrackQuality = Convert.ToBoolean(reader.ReadElementContentAsInt());
                                            break;
                                        case "TrackDownloadErrors":
                                            result.TrackDownloadErrors = Convert.ToBoolean(reader.ReadElementContentAsInt());
                                            break;
                                        case "AggregationIntervalMilliseconds":
                                            result.AggregationInterval = TimeSpan.FromMilliseconds(reader.ReadElementContentAsInt());
                                            break;
                                        case "TrackQualitySnapshot":
                                            result.TrackQualitySnapshot = Convert.ToBoolean(reader.ReadElementContentAsInt());
                                            break;
                                        case "SnapshotIntervalMilliseconds":
                                            result.SnapshotInterval = TimeSpan.FromMilliseconds(reader.ReadElementContentAsInt());
                                            break;
                                        case "LatencyAlertThreshold":
                                            result.LatencyAlertThreshold = reader.ReadElementContentAsFloat();
                                            break;
                                        case "RecordTraceLogs":
                                            result.RecordTraceLogs = Convert.ToBoolean(reader.ReadElementContentAsInt());
                                            break;
                                        case "QualityTracking":
                                            result.QualityConfig = QualityConfig.Load(reader);
                                            break;
                                        default:
                                            reader.Skip();
                                            break;
                                    }
                                }
                                reader.ReadEndElement();
                            }
                            else
                                reader.Skip();
                            break;

                        default:
                            reader.Skip();
                            break;
                    }
                }
                reader.ReadEndElement();
            }
            else
                reader.Skip();

            return result;
        }
        /// <summary>
        /// Creates an instance of the main diagnostic config object from an XmlReader
        /// </summary>
        public static DiagnosticsConfig Load(XmlReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            var result = new DiagnosticsConfig();
            List <EdgeServerRules> edgeServerRuleCollection = null;

            reader.GoToElement();
            reader.ReadStartElement();
            if (!reader.IsEmptyElement)
            {
                while (reader.GoToSibling())
                {
                    switch (reader.LocalName)
                    {
                    case "TraceMonitor":
                        result.TracingConfig = TracingConfig.Load(reader);
                        break;

                    case "EdgeServerRules":
                        if (!reader.IsEmptyElement)
                        {
                            if (edgeServerRuleCollection == null)
                            {
                                edgeServerRuleCollection        = new List <EdgeServerRules>();
                                result.EdgeServerRuleCollection = edgeServerRuleCollection;
                            }
                            edgeServerRuleCollection.Add(EdgeServerRules.Load(reader));
                        }
                        else
                        {
                            reader.Skip();
                        }
                        break;

                    case "Diagnostics":
                        if (!reader.IsEmptyElement)
                        {
                            reader.ReadStartElement();
                            while (reader.GoToSibling())
                            {
                                switch (reader.LocalName)
                                {
                                case "TrackQuality":
                                    result.TrackQuality = Convert.ToBoolean(reader.ReadElementContentAsInt());
                                    break;

                                case "TrackDownloadErrors":
                                    result.TrackDownloadErrors = Convert.ToBoolean(reader.ReadElementContentAsInt());
                                    break;

                                case "AggregationIntervalMilliseconds":
                                    result.AggregationInterval = TimeSpan.FromMilliseconds(reader.ReadElementContentAsInt());
                                    break;

                                case "TrackQualitySnapshot":
                                    result.TrackQualitySnapshot = Convert.ToBoolean(reader.ReadElementContentAsInt());
                                    break;

                                case "SnapshotIntervalMilliseconds":
                                    result.SnapshotInterval = TimeSpan.FromMilliseconds(reader.ReadElementContentAsInt());
                                    break;

                                case "LatencyAlertThreshold":
                                    result.LatencyAlertThreshold = reader.ReadElementContentAsFloat();
                                    break;

                                case "RecordTraceLogs":
                                    result.RecordTraceLogs = Convert.ToBoolean(reader.ReadElementContentAsInt());
                                    break;

                                case "QualityTracking":
                                    result.QualityConfig = QualityConfig.Load(reader);
                                    break;

                                default:
                                    reader.Skip();
                                    break;
                                }
                            }
                            reader.ReadEndElement();
                        }
                        else
                        {
                            reader.Skip();
                        }
                        break;

                    default:
                        reader.Skip();
                        break;
                    }
                }
                reader.ReadEndElement();
            }
            else
            {
                reader.Skip();
            }

            return(result);
        }