Closed snowlyg closed 2 years ago
I change MetricsList []*Metric to MetricsList map[string]*Metric, when i use the custom metrics. Make a easy way to get custom metric.
MetricsList []*Metric
MetricsList map[string]*Metric
customMetrics := []*ginprometheus.Metric{ &ginprometheus.Metric{ ID: "1234", // optional string Name: "test_metric", // required string Description: "Counter test metric", // required string Type: "counter", // required string }, &ginprometheus.Metric{ ID: "1235", // Identifier Name: "test_metric_2", // Metric Name Description: "Summary test metric", // Help Description Type: "summary", // type associated with prometheus collector }, // Type Options: // counter, counter_vec, gauge, gauge_vec, // histogram, histogram_vec, summary, summary_vec } p := ginprometheus.NewPrometheus("gin", customMetrics) // add data to custom metrics m := p.MetricsList["1234"].MetricCollector.(prometheus.Counter) m.Inc()
I change
MetricsList []*Metric
toMetricsList map[string]*Metric
, when i use the custom metrics. Make a easy way to get custom metric.25