/// <summary> /// Samples a client metric. These metrics are only sample when self reporting is enabled. /// </summary> /// <param name="name">The name.</param> /// <param name="value">The value.</param> public void SampleClientMetric(string name, double value) { if (double.IsInfinity(value) || double.IsNaN(value)) { return; } if (!this.clientMetrics.ContainsKey(name)) { UserReportMetric newUserReportMetric = new UserReportMetric(); newUserReportMetric.Name = name; this.clientMetrics.Add(name, newUserReportMetric); } UserReportMetric userReportMetric = this.clientMetrics[name]; userReportMetric.Sample(value); this.clientMetrics[name] = userReportMetric; // Self Reporting if (this.IsSelfReporting) { this.SampleMetric(name, value); } }
/// <summary> /// Samples a metric. Metrics can be sampled frequently and have low overhead. /// </summary> /// <param name="name">The name.</param> /// <param name="value">The value.</param> public void SampleMetric(string name, double value) { if (this.Configuration.MetricsGatheringMode == MetricsGatheringMode.Disabled) { return; } if (double.IsInfinity(value) || double.IsNaN(value)) { return; } if (!this.currentMetrics.ContainsKey(name)) { UserReportMetric newUserReportMetric = new UserReportMetric(); newUserReportMetric.Name = name; this.currentMetrics.Add(name, newUserReportMetric); } UserReportMetric userReportMetric = this.currentMetrics[name]; userReportMetric.Sample(value); this.currentMetrics[name] = userReportMetric; }