public void ReportGauge()

in src/Infrastructure/Utils/PrometheusUtils.cs [19:46]


        public void ReportGauge(
            ConcurrentDictionary<string, Collector> cache,
            string metricName,
            double metricValue,
            Dictionary<string, string> labels,
            string helpMessage = "")
        {
            if (cache == null ||
                metricName == null || metricName.Equals(string.Empty) ||
                labels == null)
            {
                throw new ArgumentException($"Invalid arguments were passed." +
                                            $"Dictionary - cannot be null: {cache}," +
                                            $"MetricName - cannot be null or empty: {metricName}," +
                                            $"MetricValue - cannot be lower than 0: {metricValue}," +
                                            $"Labels - cannot be null: {labels}," +
                                            $"HelpMessage - cannot be null: {helpMessage}.");
            }

            helpMessage = helpMessage ?? string.Empty;

            // Adding or getting the gauge and reporting it.
            ((Gauge)cache.GetOrAdd(
                    metricName,
                    f => Metrics.CreateGauge(metricName, helpMessage, new GaugeConfiguration().LabelNames = labels.Keys.ToArray())))
                .WithLabels(labels.Values.ToArray())
                .Set(metricValue);
        }