From b9e7bbd5feab2f3de1bfb6ff08df905ebb293f8b Mon Sep 17 00:00:00 2001 From: Daniel Czerwonk Date: Fri, 1 Dec 2017 08:34:57 +0100 Subject: [PATCH] fixed naming inconsistency --- README.md | 4 ++-- metric_collector.go | 2 +- metrics/exporter.go | 4 ++-- metrics/generic_exporter.go | 23 ++++++++++++++++------- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 133f023..e399287 100644 --- a/README.md +++ b/README.md @@ -30,8 +30,8 @@ ospfv3_running{name="ospf1"} 1 ### new format ``` -bird_protocol_prefix_count_import{name="bgp1",proto="BGP",ip_version="4"} 600000 -bird_protocol_prefix_count_import{name="bgp1",proto="BGP",ip_version="6"} 50000 +bird_protocol_prefix_import_count{name="bgp1",proto="BGP",ip_version="4"} 600000 +bird_protocol_prefix_import_count{name="bgp1",proto="BGP",ip_version="6"} 50000 bird_ospfv3_running{name="ospf1"} 1 ``` diff --git a/metric_collector.go b/metric_collector.go index 159c053..59bdd82 100644 --- a/metric_collector.go +++ b/metric_collector.go @@ -40,7 +40,7 @@ func exportersForLegacy() map[int][]metrics.MetricExporter { func exportersForDefault() map[int][]metrics.MetricExporter { l := &metrics.DefaultLabelStrategy{} - e := metrics.NewGenericProtocolMetricExporter("bird_protocol", l) + e := metrics.NewGenericProtocolMetricExporter("bird_protocol", true, l) return map[int][]metrics.MetricExporter{ protocol.BGP: []metrics.MetricExporter{e}, diff --git a/metrics/exporter.go b/metrics/exporter.go index 8ea3017..6274406 100644 --- a/metrics/exporter.go +++ b/metrics/exporter.go @@ -12,8 +12,8 @@ type ProtocolMetricExporter struct { func NewMetricExporter(prefixIpv4, prefixIpv6 string, labelStrategy LabelStrategy) *ProtocolMetricExporter { return &ProtocolMetricExporter{ - ipv4Exporter: NewGenericProtocolMetricExporter(prefixIpv4, labelStrategy), - ipv6Exporter: NewGenericProtocolMetricExporter(prefixIpv6, labelStrategy), + ipv4Exporter: NewGenericProtocolMetricExporter(prefixIpv4, false, labelStrategy), + ipv6Exporter: NewGenericProtocolMetricExporter(prefixIpv6, false, labelStrategy), } } diff --git a/metrics/generic_exporter.go b/metrics/generic_exporter.go index 0019bdf..75ff5e5 100644 --- a/metrics/generic_exporter.go +++ b/metrics/generic_exporter.go @@ -35,20 +35,29 @@ type GenericProtocolMetricExporter struct { withdrawsExportAcceptCountDesc *prometheus.Desc } -func NewGenericProtocolMetricExporter(prefix string, labelStrategy LabelStrategy) *GenericProtocolMetricExporter { +func NewGenericProtocolMetricExporter(prefix string, newNaming bool, labelStrategy LabelStrategy) *GenericProtocolMetricExporter { m := &GenericProtocolMetricExporter{labelStrategy: labelStrategy} - m.initDesc(prefix) + m.initDesc(prefix, newNaming) return m } -func (m *GenericProtocolMetricExporter) initDesc(prefix string) { +func (m *GenericProtocolMetricExporter) initDesc(prefix string, newNaming bool) { labels := m.labelStrategy.labelNames() m.upDesc = prometheus.NewDesc(prefix+"_up", "Protocol is up", labels, nil) - m.importCountDesc = prometheus.NewDesc(prefix+"_prefix_count_import", "Number of imported routes", labels, nil) - m.exportCountDesc = prometheus.NewDesc(prefix+"_prefix_count_export", "Number of exported routes", labels, nil) - m.filterCountDesc = prometheus.NewDesc(prefix+"_prefix_count_filter", "Number of filtered routes", labels, nil) - m.preferredCountDesc = prometheus.NewDesc(prefix+"_prefix_count_preferred", "Number of preferred routes", labels, nil) + + if newNaming { + m.importCountDesc = prometheus.NewDesc(prefix+"_prefix_import_count", "Number of imported routes", labels, nil) + m.exportCountDesc = prometheus.NewDesc(prefix+"_prefix_export_count", "Number of exported routes", labels, nil) + m.filterCountDesc = prometheus.NewDesc(prefix+"_prefix_filter_count", "Number of filtered routes", labels, nil) + m.preferredCountDesc = prometheus.NewDesc(prefix+"_prefix_preferred_count", "Number of preferred routes", labels, nil) + } else { + m.importCountDesc = prometheus.NewDesc(prefix+"_prefix_count_import", "Number of imported routes", labels, nil) + m.exportCountDesc = prometheus.NewDesc(prefix+"_prefix_count_export", "Number of exported routes", labels, nil) + m.filterCountDesc = prometheus.NewDesc(prefix+"_prefix_count_filter", "Number of filtered routes", labels, nil) + m.preferredCountDesc = prometheus.NewDesc(prefix+"_prefix_count_preferred", "Number of preferred routes", labels, nil) + } + m.uptimeDesc = prometheus.NewDesc(prefix+"_uptime", "Uptime of the protocol in seconds", labels, nil) m.updatesImportIgnoreCountDesc = prometheus.NewDesc(prefix+"_changes_update_import_ignore_count", "Number of incoming updates beeing ignored", labels, nil) m.updatesImportAcceptCountDesc = prometheus.NewDesc(prefix+"_changes_update_import_accept_count", "Number of incoming updates beeing accepted", labels, nil)