/// <summary> /// Sets a new value for a measurement on a gauge /// </summary> /// <param name="name">Name of the metric</param> /// <param name="description">Description of the metric</param> /// <param name="value">New measured value</param> /// <param name="labels">Labels that are applicable for this measurement</param> public void WriteGaugeMeasurement(string name, string description, double value, Dictionary <string, string> labels) { var enableMetricTimestamps = _prometheusConfiguration.CurrentValue.EnableMetricTimestamps; var metricsDeclaration = _metricsDeclarationProvider.Get(applyDefaults: true); if (labels.ContainsKey("tenant_id") == false) { labels.Add("tenant_id", metricsDeclaration.AzureMetadata.TenantId); } var orderedLabels = labels.OrderByDescending(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value); _prometheusMetricsCollector.WriteGaugeMeasurement(name, description, value, orderedLabels, enableMetricTimestamps); }
protected void WritePrometheusMetric(string metricName, string metricDescription, int value, Dictionary <string, string> labels) { _prometheusMetricsCollector.WriteGaugeMeasurement(metricName, metricDescription, value, labels, includeTimestamp: true); }