From aae44d410543299cd392f9d464882da4b98f915f Mon Sep 17 00:00:00 2001 From: SuperQ Date: Sat, 1 Jul 2023 08:13:03 +0200 Subject: [PATCH] Sort source names Sort the list of source names to make the label value consistent. * Bump time Go mod. Fixes: https://github.com/SuperQ/chrony_exporter/issues/25 Signed-off-by: SuperQ --- collector/sources.go | 2 ++ go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/collector/sources.go b/collector/sources.go index 20ec061..bebb7a3 100644 --- a/collector/sources.go +++ b/collector/sources.go @@ -18,6 +18,7 @@ import ( "fmt" "math" "net" + "sort" "strings" "github.com/facebook/time/ntp/chrony" @@ -122,6 +123,7 @@ func (e Exporter) getSourcesMetrics(ch chan<- prometheus.Metric, client chrony.C sourceAddress := r.IPAddr.String() // Ignore reverse lookup errors. sourceNames, _ := net.LookupAddr(sourceAddress) + sort.Strings(sourceNames) sourceName := strings.Join(sourceNames, ",") if r.Mode == chrony.SourceModeRef && r.IPAddr.To4() != nil { diff --git a/go.mod b/go.mod index 8c5a1e4..04df5a8 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.19 require ( github.com/alecthomas/kingpin/v2 v2.3.2 - github.com/facebook/time v0.0.0-20230328101046-54fdb4d16625 + github.com/facebook/time v0.0.0-20230529151911-512b3b30ab23 github.com/go-kit/log v0.2.1 github.com/prometheus/client_golang v1.16.0 github.com/prometheus/common v0.44.0 diff --git a/go.sum b/go.sum index 737c87e..bcf2501 100644 --- a/go.sum +++ b/go.sum @@ -12,8 +12,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/facebook/time v0.0.0-20230328101046-54fdb4d16625 h1:n9sqA4q62V8p3b7hcotw23eP1k3KETSJpJdO6uzPYCk= -github.com/facebook/time v0.0.0-20230328101046-54fdb4d16625/go.mod h1:dfouHrgxDA7FxAzPYOFIGHFcrFlG2trLpeLtA5+hs+Q= +github.com/facebook/time v0.0.0-20230529151911-512b3b30ab23 h1:2bNmQUpwOmOwPrUFts4znQaefE8fYMzf3yutKzWztWM= +github.com/facebook/time v0.0.0-20230529151911-512b3b30ab23/go.mod h1:dfouHrgxDA7FxAzPYOFIGHFcrFlG2trLpeLtA5+hs+Q= github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA=