Skip to content

Commit

Permalink
Update version collector
Browse files Browse the repository at this point in the history
Update version collector use to follow common exporter pattern.

Signed-off-by: SuperQ <[email protected]>
  • Loading branch information
SuperQ committed Sep 28, 2024
1 parent 750bcf7 commit a9454f5
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ import (
"github.com/prometheus-community/systemd_exporter/systemd"
"github.com/prometheus-community/systemd_exporter/systemd/resolved"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/collectors/version"
versioncollector "github.com/prometheus/client_golang/prometheus/collectors/version"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/prometheus/common/promslog"
"github.com/prometheus/common/promslog/flag"
commonVersion "github.com/prometheus/common/version"
"github.com/prometheus/common/version"
"github.com/prometheus/exporter-toolkit/web"
webflag "github.com/prometheus/exporter-toolkit/web/kingpinflag"
)
Expand All @@ -52,18 +52,18 @@ func main() {

promslogConfig := &promslog.Config{}
flag.AddFlags(kingpin.CommandLine, promslogConfig)
kingpin.Version(commonVersion.Print("systemd_exporter"))
kingpin.Version(version.Print("systemd_exporter"))
kingpin.HelpFlag.Short('h')
kingpin.Parse()
logger := promslog.New(promslogConfig)

logger.Info("Starting systemd_exporter", "version", commonVersion.Info())
logger.Info("Build context", "build_context", commonVersion.BuildContext())
logger.Info("Starting systemd_exporter", "version", version.Info())
logger.Info("Build context", "build_context", version.BuildContext())

exporterMetricsRegistry := prometheus.NewRegistry()
r := prometheus.NewRegistry()

r.MustRegister(version.NewCollector("systemd_exporter"))
r.MustRegister(versioncollector.NewCollector("systemd_exporter"))

collector, err := systemd.NewCollector(logger)
if err != nil {
Expand Down Expand Up @@ -107,7 +107,7 @@ func main() {
landingConfig := web.LandingConfig{
Name: "systemd Exporter",
Description: "Prometheus Exporter for systemd",
Version: commonVersion.Info(),
Version: version.Info(),
Links: []web.LandingLinks{
{
Address: *metricsPath,
Expand Down

0 comments on commit a9454f5

Please sign in to comment.