/// <summary>
 /// Initializes a new instance of the <see cref="SmartSignalRunner"/> class.
 /// </summary>
 /// <param name="smartSignal">The smart signal.</param>
 /// <param name="analysisServicesFactory">The analysis services factory.</param>
 /// <param name="queryRunInfoProvider">The query run information provider.</param>
 /// <param name="smartSignalManifest">The smart signal manifest.</param>
 /// <param name="tracer">The tracer.</param>
 public SmartSignalRunner(
     ISmartSignal smartSignal,
     IAnalysisServicesFactory analysisServicesFactory,
     IQueryRunInfoProvider queryRunInfoProvider,
     SmartSignalManifest smartSignalManifest,
     ITracer tracer)
 {
     this.smartSignal             = smartSignal;
     this.analysisServicesFactory = analysisServicesFactory;
     this.queryRunInfoProvider    = queryRunInfoProvider;
     this.smartSignalManifes      = smartSignalManifest;
     this.Tracer          = tracer;
     this.IsSignalRunning = false;
     this.Results         = new ObservableCollection <SignalResultItem>();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SmartSignalRunner"/> class
 /// </summary>
 /// <param name="smartSignalRepository">The smart signals repository</param>
 /// <param name="smartSignalLoader">The smart signals loader</param>
 /// <param name="analysisServicesFactory">The analysis services factory</param>
 /// <param name="azureResourceManagerClient">The azure resource manager client</param>
 /// <param name="queryRunInfoProvider">The query run information provider</param>
 /// <param name="tracer">The tracer</param>
 public SmartSignalRunner(
     ISmartSignalRepository smartSignalRepository,
     ISmartSignalLoader smartSignalLoader,
     IAnalysisServicesFactory analysisServicesFactory,
     IAzureResourceManagerClient azureResourceManagerClient,
     IQueryRunInfoProvider queryRunInfoProvider,
     ITracer tracer)
 {
     this.smartSignalRepository      = Diagnostics.EnsureArgumentNotNull(() => smartSignalRepository);
     this.smartSignalLoader          = Diagnostics.EnsureArgumentNotNull(() => smartSignalLoader);
     this.analysisServicesFactory    = Diagnostics.EnsureArgumentNotNull(() => analysisServicesFactory);
     this.azureResourceManagerClient = Diagnostics.EnsureArgumentNotNull(() => azureResourceManagerClient);
     this.queryRunInfoProvider       = Diagnostics.EnsureArgumentNotNull(() => queryRunInfoProvider);
     this.tracer = tracer;
 }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SmartDetectorRunner"/> class.
 /// </summary>
 /// <param name="smartDetector">The Smart Detector.</param>
 /// <param name="analysisServicesFactory">The analysis services factory.</param>
 /// <param name="queryRunInfoProvider">The query run information provider.</param>
 /// <param name="smartDetectorManifes">The Smart Detector manifest.</param>
 /// <param name="stateRepositoryFactory">The state repository factory</param>
 /// <param name="smartDetectorId">The id of the Smart Detector</param>
 /// <param name="tracer">The tracer.</param>
 public SmartDetectorRunner(
     ISmartDetector smartDetector,
     IAnalysisServicesFactory analysisServicesFactory,
     IQueryRunInfoProvider queryRunInfoProvider,
     SmartDetectorManifest smartDetectorManifes,
     IStateRepositoryFactory stateRepositoryFactory,
     string smartDetectorId,
     ITracer tracer)
 {
     this.smartDetector           = smartDetector;
     this.analysisServicesFactory = analysisServicesFactory;
     this.queryRunInfoProvider    = queryRunInfoProvider;
     this.smartDetectorManifes    = smartDetectorManifes;
     this.Tracer = tracer;
     this.IsSmartDetectorRunning = false;
     this.Alerts = new ObservableCollection <EmulationAlert>();
     this.stateRepositoryFactory = stateRepositoryFactory;
     this.smartDetectorId        = smartDetectorId;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="AnalysisRequest"/> class.
        /// </summary>
        /// <param name="requestParameters">The request parameters as received from the Azure Monitoring back-end.</param>
        /// <param name="analysisServicesFactory">The analysis services factory to be used for querying the resources telemetry.</param>
        /// <param name="stateRepository">The persistent state repository for storing state between analysis runs</param>
        public AnalysisRequest(
            AnalysisRequestParameters requestParameters,
            IAnalysisServicesFactory analysisServicesFactory,
            IStateRepository stateRepository)
        {
            if (requestParameters == null)
            {
                throw new ArgumentNullException(nameof(requestParameters));
            }

            if (analysisServicesFactory == null)
            {
                throw new ArgumentNullException(nameof(analysisServicesFactory));
            }

            this.RequestParameters       = requestParameters;
            this.AnalysisServicesFactory = analysisServicesFactory;
            this.StateRepository         = stateRepository;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MetricChartPropertyControlViewModel"/> class.
        /// </summary>
        /// <param name="metricChartAlertProperty">The metric chart alert property that should be displayed.</param>
        /// <param name="analysisServicesFactory">The analysis services factory</param>
        /// <param name="tracer">The tracer</param>
        public MetricChartPropertyControlViewModel(
            MetricChartAlertProperty metricChartAlertProperty,
            IAnalysisServicesFactory analysisServicesFactory,
            ITracer tracer)
        {
            this.metricChartAlertProperty = metricChartAlertProperty;

            this.Title = metricChartAlertProperty.DisplayName;
            this.analysisServicesFactory = analysisServicesFactory;
            this.tracer = tracer;

            // Set X/Y axis formatters
            this.XAxisFormatter = value => (value >= 0 ? new DateTime((long)(value * TimeSpan.FromHours(1).Ticks)) : DateTime.MinValue).ToString(CultureInfo.InvariantCulture);
            this.YAxisFormatter = value => value.ToString(CultureInfo.InvariantCulture);

            // Start a task to read the metric values
            this.ReadChartValuesTask = new ObservableTask <ChartValues <DateTimePoint> >(
                this.ReadChartValuesAsync(),
                tracer);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="AnalysisRequest"/> struct.
        /// </summary>
        /// <param name="targetResources">The list of resource identifiers to analyze.</param>
        /// <param name="analysisCadence">The analysis cadence defined in the Alert Rule which initiated the Smart Detector's analysis.</param>
        /// <param name="alertRuleResourceId">The alert rule resource ID.</param>
        /// <param name="analysisServicesFactory">The analysis services factory to be used for querying the resources telemetry.</param>
        /// <param name="stateRepository">The persistent state repository for storing state between analysis runs</param>
        public AnalysisRequest(List <ResourceIdentifier> targetResources, TimeSpan analysisCadence, string alertRuleResourceId, IAnalysisServicesFactory analysisServicesFactory, IStateRepository stateRepository)
        {
            // Parameter validations
            if (targetResources == null)
            {
                throw new ArgumentNullException(nameof(targetResources));
            }
            else if (!targetResources.Any())
            {
                throw new ArgumentException("Analysis request must have at least one target resource", nameof(targetResources));
            }

            if (analysisCadence <= TimeSpan.Zero)
            {
                throw new ArgumentException("Analysis cadence must represent a positive time span", nameof(analysisCadence));
            }

            if (analysisServicesFactory == null)
            {
                throw new ArgumentNullException(nameof(analysisServicesFactory));
            }

            this.TargetResources         = targetResources;
            this.AnalysisCadence         = analysisCadence;
            this.AlertRuleResourceId     = alertRuleResourceId;
            this.AnalysisServicesFactory = analysisServicesFactory;
            this.StateRepository         = stateRepository;
        }
Пример #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AnalysisRequest"/> struct.
        /// </summary>
        /// <param name="targetResources">The list of resource identifiers to analyze.</param>
        /// <param name="dataEndTime">The data end time to query</param>
        /// <param name="analysisCadence">The analysis cadence defined in the Alert Rule which initiated the Smart Detector's analysis.</param>
        /// <param name="alertRuleResourceId">The alert rule resource ID.</param>
        /// <param name="analysisServicesFactory">The analysis services factory to be used for querying the resources telemetry.</param>
        /// <param name="stateRepository">The persistent state repository for storing state between analysis runs</param>
        public AnalysisRequest(List <ResourceIdentifier> targetResources, DateTime dataEndTime, TimeSpan analysisCadence, string alertRuleResourceId, IAnalysisServicesFactory analysisServicesFactory, IStateRepository stateRepository)
        {
            // Parameter validations
            if (targetResources == null)
            {
                throw new ArgumentNullException(nameof(targetResources));
            }
            else if (!targetResources.Any())
            {
                throw new ArgumentException("Analysis request must have at least one target resource", nameof(targetResources));
            }

            if (dataEndTime.Kind != DateTimeKind.Utc)
            {
                throw new ArgumentException("Data end time must be specified in UTC", nameof(dataEndTime));
            }
            else if (dataEndTime >= DateTime.UtcNow)
            {
                throw new ArgumentException("Data end time cannot be in the future", nameof(dataEndTime));
            }

            if (analysisCadence <= TimeSpan.Zero)
            {
                throw new ArgumentException("Analysis cadence must represent a positive time span", nameof(analysisCadence));
            }

            if (analysisServicesFactory == null)
            {
                throw new ArgumentNullException(nameof(analysisServicesFactory));
            }

            this.TargetResources         = targetResources;
            this.DataEndTime             = dataEndTime;
            this.AnalysisCadence         = analysisCadence;
            this.AlertRuleResourceId     = alertRuleResourceId;
            this.AnalysisServicesFactory = analysisServicesFactory;
            this.StateRepository         = stateRepository;
        }