internal void MeasureCriticalTime()
 {
     if (_context.SentTime != null)
     {
         PrometheusMetrics.CriticalTimer(_messageType)
         .Observe((DateTime.UtcNow - _context.SentTime.Value).TotalSeconds);
     }
 }
Exemple #2
0
        static void ConfigureMetrics(string serviceName, Action <PrometheusMetricsOptions> configure)
        {
            var options = PrometheusMetricsOptions.Default;

            configure?.Invoke(options);

            PrometheusMetrics.TryConfigure(GetServiceName(serviceName), options);
        }
        public Task ConsumeFault <T>(ConsumeContext <T> context, TimeSpan duration, string consumerType,
                                     Exception exception) where T : class
        {
            var messageType = typeof(T).Name;

            PrometheusMetrics.ErrorCounter(messageType).Inc();

            return(Task.CompletedTask);
        }
Exemple #4
0
        public static void ConnectMetrics(this IBusControl busControl, string serviceName = "")
        {
            PrometheusMetrics.TryConfigure(
                string.IsNullOrWhiteSpace(serviceName)
                    ? Path.GetFileNameWithoutExtension(Process.GetCurrentProcess().MainModule.FileName)
                    : serviceName);

            busControl.ConnectReceiveObserver(new PrometheusMetricsObservers(serviceName));
        }
Exemple #5
0
        public static void UsePrometheusMetrics <T>(this IPipeConfigurator <T> configurator,
                                                    string serviceName = null)
            where T : class, ConsumeContext
        {
            PrometheusMetrics.TryConfigure(
                string.IsNullOrWhiteSpace(serviceName)
                    ? Path.GetFileNameWithoutExtension(Process.GetCurrentProcess().MainModule.FileName)
                    : serviceName);

            configurator.AddPipeSpecification(new PrometheusSpecification <T>());
        }
        public Task PostConsume <T>(ConsumeContext <T> context, TimeSpan duration, string consumerType) where T : class
        {
            var messageType = typeof(T).Name;

            PrometheusMetrics.ConsumeTimer(messageType).Observe(duration.TotalSeconds);
            PrometheusMetrics.MessageCounter(messageType).Inc();

            if (context.SentTime != null)
            {
                PrometheusMetrics.CriticalTimer(messageType)
                .Observe((DateTime.UtcNow - context.SentTime.Value).TotalSeconds);
            }

            return(Task.CompletedTask);
        }
 internal Task Measure(Func <Task> action) => PrometheusMetrics.MeasureConsume(action, _messageType);
 internal void CountError() => PrometheusMetrics.ErrorCounter(_messageType).Inc();
 internal void CountMessage() => PrometheusMetrics.MessageCounter(_messageType).Inc();
Exemple #10
0
 public PrometheusMetricsObservers(string serviceName)
 {
     PrometheusMetrics.TryConfigure(serviceName);
 }
 internal IDisposable ConsumeTimer() => PrometheusMetrics.ConsumeTimer(_messageType).Timer();