private void _registerCustomMetrics(CustomMetricsSpec customMetricsSpec) { foreach (var summary in customMetricsSpec.Summaries) { _addSummaryReporter( Constants.PitayaKey, summary.Subsystem, summary.Name, summary.Help, summary.Labels.ToArray(), summary.Objectives); } foreach (var gauge in customMetricsSpec.Gauges) { _addGaugeReporter( Constants.PitayaKey, gauge.Subsystem, gauge.Name, gauge.Help, gauge.Labels.ToArray()); } foreach (var counter in customMetricsSpec.Counters) { _addCounterReporter( Constants.PitayaKey, counter.Subsystem, counter.Name, counter.Help, counter.Labels.ToArray()); } }
public PrometheusMetricsReporter(string serverType, string game, int port, Dictionary <string, string> constantLabels = null, Dictionary <string, string> additionalLabels = null, CustomMetricsSpec customMetricsSpec = null) { _constantLabels = constantLabels ?? new Dictionary <string, string>(); _constantLabels["game"] = game; _constantLabels["serverType"] = serverType; _additionalLabels = additionalLabels ?? new Dictionary <string, string>(); _countReportersMap = new Dictionary <string, Counter>(); _summaryReportersMap = new Dictionary <string, Summary>(); _gaugeReportersMap = new Dictionary <string, Gauge>(); if (customMetricsSpec != null) { _registerCustomMetrics(customMetricsSpec); } _registerMetrics(); var prometheusServer = new MetricServer(port: port); prometheusServer.Start(); }