Beispiel #1
0
 /// <summary>
 /// Метрики при добавлении нового cмс-сообщения
 /// </summary>
 public static void SmsAdded(this IMetric metric)
 {
     metric.IncrementCounter((options) => {
         options.Name        = "incomming_sms";
         options.LabelValues = new List <string>().ToArray();
         options.LabelNames  = new List <string>().ToArray();
     });
 }
Beispiel #2
0
        /// <summary>
        /// Appends counter metric with LogEventInfo
        /// </summary>
        /// <param name="logEvent"></param>
        private void AppendCounter(LogEventInfo logEvent)
        {
            List <string> labelNames  = new List <string>();
            List <string> labelValues = new List <string>();

            foreach (var item in logEvent.Properties)
            {
                labelNames.Add(item.Key.ToString());

                var value = item.Value ?? string.Empty;
                labelValues.Add(value.ToString());
            }

            metric.IncrementCounter(x =>
            {
                x.Name        = "service_health";
                x.Help        = $"Trace from {LoggerContext.ServiceName}";
                x.LabelNames  = labelNames.ToArray();
                x.LabelValues = labelValues.ToArray();
            });
        }