dexidp / dex

OpenID Connect (OIDC) identity and OAuth 2.0 provider with pluggable connectors
https://dexidp.io
Apache License 2.0
9.41k stars 1.69k forks source link

feat: new Prometheus metrics build_info #3558

Closed nlamirault closed 2 months ago

nlamirault commented 4 months ago

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

nabokihms commented 3 months ago

@nlamirault could you please fix the lint error?

nlamirault commented 3 months ago

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 commented 3 months ago

It should help:

make help
make fix