Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: new Prometheus metrics build_info #3558

Merged
merged 5 commits into from
Jul 15, 2024

Conversation

nlamirault
Copy link
Contributor

Overview

Add a new metric dex_build_info, with version which will be set to the Git tag version.

$ curl -s http://127.0.0.1:5558/metrics | grep build
# HELP dex_build_info A metric with a constant '1' value labeled by version from which Dex was built.
# TYPE dex_build_info gauge
dex_build_info{goarch="arm64",goversion="go1.22.2",version="43a9a144a710803b6a3036368cec3bec9f6f02de-dirty"} 1 

What this PR does / why we need it

Special notes for your reviewer

Signed-off-by: Nicolas Lamirault <nicolas.lamirault@gmail.com>
Signed-off-by: Nicolas Lamirault <nicolas.lamirault@gmail.com>
Signed-off-by: Nicolas Lamirault <nicolas.lamirault@gmail.com>
Copy link
Member

@nabokihms nabokihms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestion to make the metrics match Kubernetes build info labels:

  1. go_version instead of goversion (for readability)
  2. platform instead ofgoarch, because this label is usually used to understand where you can run the software

Overall, PR looks great! Thanks for your effort.

cmd/dex/serve.go Outdated
Namespace: "dex",
Help: "A metric with a constant '1' value labeled by version from which Dex was built.",
},
[]string{"version", "goversion", "goarch"},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[]string{"version", "goversion", "goarch"},
[]string{"version", "go_version", "platform"},

cmd/dex/serve.go Outdated Show resolved Hide resolved
Signed-off-by: Nicolas Lamirault <nicolas.lamirault@gmail.com>
@nabokihms
Copy link
Member

@nlamirault could you please fix the lint error?

@nlamirault
Copy link
Contributor Author

nlamirault commented Jun 13, 2024

I don't know how to fix that:

└─ ➜ go fmt cmd/dex/serve.go

└─ ➜ make lint
golangci-lint has version 1.59.1 built with go1.22.4 from 1a55854 on 2024-06-08T22:05:49Z
WARN [config_reader] The configuration option `run.skip-dirs` is deprecated, please use `issues.exclude-dirs`.
WARN [config_reader] The configuration option `linters.gci.local-prefixes` is deprecated, please use `prefix()` inside `linters.gci.sections`.
cmd/dex/serve.go:54: File is not `gofumpt`-ed (gofumpt)
var (
        buildInfo = prometheus.NewGaugeVec(
                prometheus.GaugeOpts{
                        Name:      "build_info",
                        Namespace: "dex",
                        Help:      "A metric with a constant '1' value labeled by version from which Dex was built.",
                },
                []string{"version", "go_version", "platform"},
        )
make: *** [lint] Error 1

@nabokihms
Copy link
Member

It should help:

make help
make fix

Signed-off-by: Nicolas Lamirault <nicolas.lamirault@gmail.com>
@nabokihms nabokihms merged commit bd73825 into dexidp:master Jul 15, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants