/// <summary> /// Creates an instance of a MetricsEvaluator. /// </summary> /// <param name="getMetrics">Gets the IMetrics of the IOrganism. /// /// No need to call any events in this delegate.</param> /// <param name="getPercentageIAlleleSimilarity">Gets the percentage that IAllele one and IAllele two are similar. /// 100% would be identical and 0% would indicate that the IAlleles share nothing.</param> /// <param name="getPercentageIGeneSimilarity">Gets the percentage that IGene one and IGene two are similar. /// 100% would be identical and 0% would indicate that the IGenes share nothing.</param> /// <param name="getPercentageIChromosomeSimilarity">Gets the percentage that IChromosome one and IChromosome two are similar. /// 100% would be identical and 0% would indicate that the IChromosomes share nothing.</param> /// <param name="getPercentageIOrganismSimilarity">Gets the percentage that IOrganism one and IOrganism two are similar. /// 100% would be identical and 0% would indicate that the IOrganisms share nothing.</param> /// <param name="metricValueComparers">The IComparers for each IMetricsValue as identified by the IMetricsValueIdentifier key.</param> public MetricsEvaluator(GetMetrics getMetrics, GetPercentageIAlleleSimilarity getPercentageIAlleleSimilarity, GetPercentageIGeneSimilarity getPercentageIGeneSimilarity, GetPercentageIChromosomeSimilarity getPercentageIChromosomeSimilarity, GetPercentageIOrganismSimilarity getPercentageIOrganismSimilarity, params KeyValuePair<IMetricsValueIdentifier, IComparer<IOrganism>>[] metricValueComparers) : base() { this.GetMetricsDelegate = getMetrics; this.GetPercentageIOrganismSimilarityDelegate = getPercentageIOrganismSimilarity; this.GetPercentageIChromosomeSimilarityDelegate = getPercentageIChromosomeSimilarity; this.GetPercentageIGeneSimilarityDelegate = getPercentageIGeneSimilarity; this.GetPercentageIAlleleSimilarityDelegate = getPercentageIAlleleSimilarity; foreach(var pair in metricValueComparers) base.MetricsValueComparers.Add(pair.Key, pair.Value); }
/// <summary> /// Initializes a new instance of the metrics type /// </summary> /// <param name="traceId">A unique identifier used to correlate the debugging and diagnostics messages</param> /// <param name="logger">An instance used to write debugging and diagnostics information</param> /// <param name="componentName">The name of the component for debugging and diagnostics messages</param> /// <param name="context">The service fabric context that is assocaited with the entity being reported on</param> /// <param name="partition">The partition of the service the metrics are being reported for</param> /// <param name="metricsCallback">The method that is called to report metrics</param> /// <param name="reportingInterval">How often the report will be sent</param> public MetricReporter(Guid traceId, ILogger logger, string componentName, ServiceContext context, IServicePartition partition, GetMetrics metricsCallback, TimeSpan?reportingInterval = null) { this.logger = logger; this.componentName = componentName; this.logger.Informational(traceId, this.componentName, "Instantiated metrics reporter"); this.interval = reportingInterval ?? TimeSpan.FromSeconds(30); if (this.interval < TimeSpan.FromSeconds(5)) { this.interval = TimeSpan.FromSeconds(15); } this.metricsCallback = metricsCallback; this.reportMetrics = context.CodePackageActivationContext.GetServiceTypes()[context.ServiceTypeName].LoadMetrics?.Select(item => item.Name).ToArray(); this.partition = partition; }
/// <summary> /// Initializes a new instance of the metrics type /// </summary> /// <param name="traceId">A unique identifier used to correlate the debugging and diagnostics messages</param> /// <param name="logger">An instance used to write debugging and diagnostics information</param> /// <param name="componentName">The name of the component for debugging and diagnostics messages</param> /// <param name="context">The service fabric context that is assocaited with the entity being reported on</param> /// <param name="partition">The partition of the service the metrics are being reported for</param> /// <param name="metricsCallback">The method that is called to report metrics</param> /// <param name="reportingInterval">How often the report will be sent</param> public MetricReporter(Guid traceId, ILogger logger, string componentName, ServiceContext context, IServicePartition partition, GetMetrics metricsCallback, TimeSpan? reportingInterval = null) { this.logger = logger; this.componentName = componentName; this.logger.Informational(traceId, this.componentName, "Instantiated metrics reporter"); this.interval = reportingInterval ?? TimeSpan.FromSeconds(30); if (this.interval < TimeSpan.FromSeconds(5)) this.interval = TimeSpan.FromSeconds(15); this.metricsCallback = metricsCallback; this.reportMetrics = context.CodePackageActivationContext.GetServiceTypes()[context.ServiceTypeName].LoadMetrics?.Select(item => item.Name).ToArray(); this.partition = partition; }