Example #1
0
        private List <Common.Monitoring.PerfmonCounterDetails> GetAllCounters(bool isReplica)
        {
            List <Common.Monitoring.PerfmonCounterDetails> perfmonCounters = new List <Common.Monitoring.PerfmonCounterDetails>();

            if (!DoNotShowDefaultCounters)
            {
                perfmonCounters = GetDefaultCounters(isReplica);
            }

            if (CounterNames != null && !CounterNames.Equals(""))
            {
                //perfmonCounters.AddRange(GetCustomCounters(isReplica, GetCounterNames(CounterNames)));
                var customCounters = GetCustomCounters(isReplica, GetCounterNames(CounterNames));
                List <Common.Monitoring.PerfmonCounterDetails> toRemove = new List <Common.Monitoring.PerfmonCounterDetails>();
                foreach (var counter in customCounters)
                {
                    foreach (var finalCounter in perfmonCounters)
                    {
                        if (counter.Counter.Equals(finalCounter.Counter, StringComparison.OrdinalIgnoreCase))
                        {
                            toRemove.Add(counter);
                        }
                    }
                }
                //perfmonCounters.AddRange(toRemove);
                foreach (var remove in toRemove)
                {
                    customCounters.Remove(remove);
                }
                perfmonCounters.AddRange(customCounters);
            }
            return(perfmonCounters);
        }
Example #2
0
 /// <summary>
 /// Increment the "Actors Stopped" counter
 /// </summary>
 /// <param name="context">The context of the actor making this call</param>
 /// <param name="value">The value of the counter. 1 by default.</param>
 /// <param name="sampleRate">The sample rate. 100% by default.</param>
 public void IncrementActorStopped(IActorContext context = null, int value = 1, double?sampleRate = null)
 {
     Registry.UpdateCounter(CounterNames.ActorsStopped, value, sampleRate ?? GlobalSampleRate);
     if (context != null)
     {
         Registry.UpdateCounter(CounterNames.ActorSpecificCategory(context, CounterNames.ActorsStopped), value, sampleRate ?? GlobalSampleRate);
     }
 }
Example #3
0
 /// <summary>
 /// Increment a custom Gauge, used to measure arbitrary values (such as the size of messages, etc... non-counter measurements)
 /// </summary>
 /// <param name="metricName">The name of the timing as it will appear in your monitoring system</param>
 /// <param name="value">The value of the gauge</param>
 /// <param name="sampleRate">The sample rate. 100% by default.</param>
 /// <param name="context">The context of the actor making this call</param>
 public void Gauge(string metricName, int value = 1, double sampleRate = 1, IActorContext context = null)
 {
     Registry.UpdateGauge(metricName, value, sampleRate);
     if (context != null)
     {
         Registry.UpdateGauge(CounterNames.ActorSpecificCategory(context, metricName), value, sampleRate);
     }
 }
Example #4
0
 /// <summary>
 /// Increment a custom timing, used to measure the elapsed time of something
 /// </summary>
 /// <param name="metricName">The name of the timing as it will appear in your monitoring system</param>
 /// <param name="time">The amount of time that elapsed, in milliseconds</param>
 /// <param name="sampleRate">The sample rate. 100% by default.</param>
 /// <param name="context">The context of the actor making this call</param>
 public void Timing(string metricName, long time, double sampleRate = 1, IActorContext context = null)
 {
     Registry.UpdateTimer(metricName, time, sampleRate);
     if (context != null)
     {
         Registry.UpdateTimer(CounterNames.ActorSpecificCategory(context, metricName), time, sampleRate);
     }
 }
Example #5
0
 /// <summary>
 /// Increment the "Infos" counter
 /// </summary>
 /// <param name="context">The context of the actor making this call</param>
 /// <param name="value">The value of the counter. 1 by default.</param>
 /// <param name="sampleRate">The sample rate. 100% by default.</param>
 public void IncrementInfosLogged(IActorContext context = null, int value = 1, double?sampleRate = null)
 {
     Registry.UpdateCounter(CounterNames.InfoMessages, value, sampleRate ?? GlobalSampleRate);
     if (context != null)
     {
         Registry.UpdateCounter(CounterNames.ActorSpecificCategory(context, CounterNames.InfoMessages), value, sampleRate ?? GlobalSampleRate);
     }
 }
Example #6
0
        public int GetCounter(CounterNames counterName)
        {
            int id = -1;

            using (var connection = GetConnection())
            {
                connection.Open();

                var command = connection.CreateCommand();
                command.CommandText = $"SELECT CounterValue FROM Counters WHERE CounterName = '{counterName}';";
                using var reader    = command.ExecuteReader();
                while (reader.Read())
                {
                    id = reader.GetInt32(0);
                }
            }

            if (id == -1)
            {
                throw new Exception("Der counterName wurde nicht gefunden");
            }

            return(id);
        }
Example #7
0
 public void IncrementCounter(CounterNames counterName)
 {
     RunCommand($"UPDATE Counters SET CounterValue = CounterValue + 1  WHERE  CounterName = '{counterName}';");
 }