Skip to content

Commit

Permalink
Update to use gauge and multiple labels
Browse files Browse the repository at this point in the history
  • Loading branch information
hsoerensen committed Jun 25, 2024
1 parent 84d805d commit f6b9842
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
6 changes: 0 additions & 6 deletions config/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package config

import (
"fmt"
"runtime"
"strconv"
)

Expand Down Expand Up @@ -136,11 +135,6 @@ func GetAlgorandVersion() string {
return currentVersion.String()
}

// GetAlgorandVersionAndBuild retrieves the current version and build
func GetAlgorandVersionAndBuild() string {
return fmt.Sprintf("algod/%d.%d.%d (%s; commit=%s) %s(%s)", currentVersion.Major, currentVersion.Minor, currentVersion.BuildNumber, currentVersion.Channel, currentVersion.CommitHash, runtime.GOOS, runtime.GOARCH)
}

// GetLicenseInfo retrieves the current license information
func GetLicenseInfo() string {
return "go-algorand is licensed with AGPLv3.0\nsource code available at https://github.com/algorand/go-algorand"
Expand Down
12 changes: 10 additions & 2 deletions daemon/algod/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"os"
"os/signal"
"path/filepath"
"runtime"
"strings"
"syscall"
"time"
Expand Down Expand Up @@ -230,8 +231,15 @@ func (s *Server) Initialize(cfg config.Local, phonebookAddresses []string, genes
NodeExporterPath: cfg.NodeExporterPath,
})

var algodEnvironmentAlgodVersionCounter = metrics.MakeCounter(metrics.MetricName{Name: "algod_environment_algod_version", Description: "Version of the Algod binary"})
algodEnvironmentAlgodVersionCounter.Inc(map[string]string{"version": config.GetAlgorandVersionAndBuild()})
var currentVersion = config.GetCurrentVersion()
var algodEnvironmentAlgodVersionGauge = metrics.MakeGauge(metrics.MetricName{Name: "algod_environment_algod_version", Description: "Version of the Algod binary"})
algodEnvironmentAlgodVersionGauge.SetLabels(1, map[string]string{
"version": fmt.Sprintf("%d.%d.%d", currentVersion.Major, currentVersion.Minor, currentVersion.BuildNumber),
"goarch": runtime.GOARCH,
"goos": runtime.GOOS,
"commit": currentVersion.CommitHash,
"channel": currentVersion.Channel,
})

Check warning on line 242 in daemon/algod/server.go

View check run for this annotation

Codecov / codecov/patch

daemon/algod/server.go#L234-L242

Added lines #L234 - L242 were not covered by tests

var serverNode ServerNode
if cfg.EnableFollowMode {
Expand Down

0 comments on commit f6b9842

Please sign in to comment.