Skip to content

Commit

Permalink
add token expiration gauge metric
Browse files Browse the repository at this point in the history
* New TokenRecorder with Gatherer and Set methods
* New gauge metric: fastly_rt_token_expiration

also: go mod tidy
  • Loading branch information
leklund committed Apr 18, 2024
1 parent b7f6cb1 commit a8f9afa
Show file tree
Hide file tree
Showing 5 changed files with 176 additions and 1,664 deletions.
14 changes: 14 additions & 0 deletions cmd/fastly-exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,20 @@ func main() {
defaultGatherers = append(defaultGatherers, dcs)
}

if !metricNameFilter.Blocked(prometheus.BuildFQName(namespace, deprecatedSubsystem, "token_expiration")) {
tokenRecorder := api.NewTokenRecorder(apiClient, token)
tg, err := tokenRecorder.Gatherer(namespace, deprecatedSubsystem)
if err != nil {
level.Error(apiLogger).Log("during", "create token gatherer", "err", err)
} else {
err = tokenRecorder.Set(context.Background())
if err != nil {
level.Error(apiLogger).Log("during", "set token gauge metric", "err", err)
}
defaultGatherers = append(defaultGatherers, tg)
}
}

var registry *prom.Registry
{
registry = prom.NewRegistry(programVersion, namespace, deprecatedSubsystem, metricNameFilter, defaultGatherers)
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/fastly/fastly-exporter

go 1.17
go 1.21

require (
github.com/cespare/xxhash v1.1.0
Expand All @@ -17,6 +17,7 @@ require (
require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
Expand Down
Loading

0 comments on commit a8f9afa

Please sign in to comment.