コード例 #1
0
 /// <summary>
 /// Counts how many times something happens per minute
 /// </summary>
 /// <param name="category">Category of the metric</param>
 /// <param name="metricName">Name of the metric</param>
 /// <param name="incrementBy"></param>
 /// <param name="autoSendIfZero">If nothing is reported for a minute, should we report a 0?</param>
 //public static void Count(string category, string metricName, int incrementBy = 1, MetricSetting advancedSettings = null)
 //{
 //    var m = new Metric(category, metricName, MetricType.Counter);
 //    m.Value = incrementBy;
 //    m.Settings = advancedSettings;
 //    StackifyLib.Internal.Metrics.MetricClient.QueueMetric(m);
 //}
 /// <summary>
 /// Counts how many times something happens per minute
 /// </summary>
 /// <param name="category">Category of the metric</param>
 /// <param name="metricName">Name of the metric</param>
 /// <param name="incrementBy"></param>
 /// <param name="autoSendIfZero">If nothing is reported for a minute, should we report a 0?</param>
 public static void Count(string category, string metricName, int incrementBy = 1, bool autoReportZeroIfNothingReported = false)
 {
     var m = new Metric(category, metricName, MetricType.Counter);
     m.Value = incrementBy;
     m.Settings = new MetricSetting() { AutoReportZeroIfNothingReported = autoReportZeroIfNothingReported };
     StackifyLib.Internal.Metrics.MetricClient.QueueMetric(m);
 }
コード例 #2
0
 /// <summary>
 /// Increment or decrement a guage metric type
 /// </summary>
 /// <param name="category">Category of the metric</param>
 /// <param name="metricName">Name of the metric</param>
 /// <param name="incrementBy">Value can be positive or negative to decrement. Defaults to 1</param>
 public static void IncrementGauge(string category, string metricName, double incrementBy, MetricSetting advancedSettings)
 {
     //leaving the count as 1 below because when it gets processed later it would sum up the count there
     var m = new Metric(category, metricName, MetricType.MetricLast);
     m.Value = incrementBy;
     m.IsIncrement = true;
     m.Settings = advancedSettings;
     StackifyLib.Internal.Metrics.MetricClient.QueueMetric(m);
 }
コード例 #3
0
 public MetricAggregate(Metric metric)
 {
     Name = metric.Name;
     Category = metric.Category;
     MetricType = metric.MetricType;
     Value = 0;
     Count = 0;
     NameKey = metric.CalcNameKey();
     OccurredUtc = metric.GetRoundedTime();
 }
コード例 #4
0
        /// <summary>
        /// Guage type metric that reports the last value reported once a minute
        /// </summary>
        /// <param name="category">Category of the metric</param>
        /// <param name="metricName">Name of the metric</param>
        /// <param name="value">Explicit value to set the metric to</param>
        //public static void SetGauge(string category, string metricName, double value, MetricSetting advancedSettings = null)
        //{
        //    var m = new Metric(category, metricName, MetricType.MetricLast) { Value = value, Settings = advancedSettings };
        //    StackifyLib.Internal.Metrics.MetricClient.QueueMetric(m);
        //}

        /// <summary>
        /// Guage type metric that reports the last value reported once a minute
        /// </summary>
        /// <param name="category">Category of the metric</param>
        /// <param name="metricName">Name of the metric</param>
        /// <param name="value">Explicit value to set the metric to</param>
        /// <param name="autoResendLastValueIfNothingReported">Every minute resend the last value if nothing reported</param>
        public static void SetGauge(string category, string metricName, double value, bool autoResendLastValueIfNothingReported = false)
        {
            var m = new Metric(category, metricName, MetricType.MetricLast) { Value = value, Settings = new MetricSetting() { AutoReportLastValueIfNothingReported = autoResendLastValueIfNothingReported } };
            StackifyLib.Internal.Metrics.MetricClient.QueueMetric(m);
        }
コード例 #5
0
 /// <summary>
 /// Sums up the values passed in and reports the total once per minute
 /// </summary>
 /// <param name="category">Category of the metric</param>
 /// <param name="metricName">Name of the metric</param>
 /// <param name="value"></param>
 public static void Sum(string category, string metricName, double value, MetricSetting advancedSettings = null)
 {
     var m = new Metric(category, metricName, MetricType.Counter);
     m.Value = value;
     m.Settings = advancedSettings;
     StackifyLib.Internal.Metrics.MetricClient.QueueMetric(m);
 }
コード例 #6
0
 /// <summary>
 /// Sums up the values passed in and reports the average of the values once per minute
 /// </summary>
 /// <param name="category">Category of the metric</param>
 /// <param name="metricName">Name of the metric</param>
 /// <param name="value"></param>
 public static void Average(string category, string metricName, double value, MetricSetting advancedSettings = null)
 {
     var m = new Metric(category, metricName, MetricType.MetricAverage) { Value = value, Settings = advancedSettings };
     StackifyLib.Internal.Metrics.MetricClient.QueueMetric(m);
 }
コード例 #7
0
 public static void QueueMetric(Metric metric)
 {
     try
     {
         _MetricQueue.Enqueue(metric);
     }
     catch(Exception ex)
     {
         Utils.StackifyAPILogger.Log(ex.ToString());
     }
 }
コード例 #8
0
 /// <summary>
 /// Increment or decrement a guage metric type
 /// </summary>
 /// <param name="category">Category of the metric</param>
 /// <param name="metricName">Name of the metric</param>
 /// <param name="incrementBy">Value can be positive or negative to decrement. Defaults to 1</param>
 //public static void IncrementGauge(string category, string metricName, double incrementBy = 1, MetricSetting advancedSettings = null)
 //{
 //    //leaving the count as 1 below because when it gets processed later it would sum up the count there
 //    var m = new Metric(category, metricName, MetricType.MetricLast);
 //    m.Value = incrementBy;
 //    m.IsIncrement = true;
 //    m.Settings = advancedSettings;
 //    StackifyLib.Internal.Metrics.MetricClient.QueueMetric(m);
 //}
 /// <summary>
 /// Increment or decrement a guage metric type
 /// </summary>
 /// <param name="category">Category of the metric</param>
 /// <param name="metricName">Name of the metric</param>
 /// <param name="incrementBy">Value can be positive or negative to decrement. Defaults to 1</param>
 /// <param name="autoResendLastValueIfNothingReported">Every minute resend the last value if nothing reported</param>
 public static void IncrementGauge(string category, string metricName, double incrementBy = 1, bool autoResendLastValueIfNothingReported = false)
 {
     //leaving the count as 1 below because when it gets processed later it would sum up the count there
     var m = new Metric(category, metricName, MetricType.MetricLast);
     m.Value = incrementBy;
     m.IsIncrement = true;
     m.Settings = new MetricSetting() { AutoReportLastValueIfNothingReported = autoResendLastValueIfNothingReported };
     StackifyLib.Internal.Metrics.MetricClient.QueueMetric(m);
 }
コード例 #9
0
 public static void QueueMetric(Metric metric)
 {
     try
     {
         //set a sanity cap
         if (_MetricQueue.Count < 100000)
         {
             _MetricQueue.Enqueue(metric);
         }
     }
     catch(Exception ex)
     {
         Utils.StackifyAPILogger.Log(ex.ToString());
     }
 }