You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
forgejo/modules
Michal 5ae07d4c2f
include build info in Prometheus metrics (#22819)
Related to: https://github.com/go-gitea/gitea/issues/18061

This PR adds build info to the Prometheus metrics. This includes:
- goarch: https://pkg.go.dev/runtime#GOARCH
- goos: https://pkg.go.dev/runtime#pkg-constants
- goversion: https://pkg.go.dev/runtime#Version
- gitea version: just exposes the existing
code.gitea.io/gitea/modules/setting.AppVer

It's a similar approach to what some other Golang projects are doing,
e.g. Prometheus:
https://github.com/prometheus/common/blob/main/version/info.go

example /metrics response from Prometheus:
```
# HELP prometheus_build_info A metric with a constant '1' value labeled by version, revision, branch, goversion from which prometheus was built, and the goos and goarch for the build.
# TYPE prometheus_build_info gauge
prometheus_build_info{branch="HEAD",goarch="amd64",goos="linux",goversion="go1.19.4",revision="c0d8a56c69014279464c0e15d8bfb0e153af0dab",version="2.41.0"} 1
```

/metrics response from gitea with this PR:
```
# HELP gitea_build_info Build information
# TYPE gitea_build_info gauge
gitea_build_info{goarch="amd64",goos="linux",goversion="go1.20",version="2c6cc0b8c"} 1
```

Signed-off-by: Michal Wasilewski <mwasilewski@gmx.com>

<!--

Please check the following:

1. Make sure you are targeting the `main` branch, pull requests on
release branches are only allowed for bug fixes.
2. Read contributing guidelines:
https://github.com/go-gitea/gitea/blob/main/CONTRIBUTING.md
3. Describe what your pull request does and which issue you're targeting
(if any)

-->

Signed-off-by: Michal Wasilewski <mwasilewski@gmx.com>
1 year ago
..
actions Fix actions workflow branches match bug (#22724) 1 year ago
activitypub Add Chef package registry (#22554) 1 year ago
analyze Implement FSFE REUSE for golang files (#21840) 2 years ago
auth Map OIDC groups to Orgs/Teams (#21441) 1 year ago
avatar Unify hashing for avatar (#22289) 2 years ago
base Implement FSFE REUSE for golang files (#21840) 2 years ago
cache Fix get system setting bug when enabled redis cache (#22295) 2 years ago
charset Fix line spacing for plaintext previews (#22699) 1 year ago
container Implement FSFE REUSE for golang files (#21840) 2 years ago
context Map OIDC groups to Orgs/Teams (#21441) 1 year ago
csv Implement FSFE REUSE for golang files (#21840) 2 years ago
doctor Add cron method to gc LFS MetaObjects (#22385) 1 year ago
emoji Fix unstable emoji sort (#22346) 2 years ago
eventsource Move `convert` package to services (#22264) 2 years ago
generate Implement FSFE REUSE for golang files (#21840) 2 years ago
git Refactor legacy strange git operations (#22756) 1 year ago
gitgraph Refactor git command package to improve security and maintainability (#22678) 1 year ago
graceful Implement FSFE REUSE for golang files (#21840) 2 years ago
hcaptcha Consume hcaptcha and pwn deps (#22610) 1 year ago
highlight Implement FSFE REUSE for golang files (#21840) 2 years ago
hostmatcher Implement FSFE REUSE for golang files (#21840) 2 years ago
html Implement FSFE REUSE for golang files (#21840) 2 years ago
httpcache Add some comments for recent code (#22725) 1 year ago
httplib Implement FSFE REUSE for golang files (#21840) 2 years ago
indexer refactor some functions to support ctx as first parameter (#21878) 2 years ago
issue/template Allow issue templates to not render title (#22589) 1 year ago
json Update gitea-vet to check FSFE REUSE (#22004) 2 years ago
lfs Implement FSFE REUSE for golang files (#21840) 2 years ago
log Improve trace logging for pulls and processes (#22633) 1 year ago
markup Fix README TOC links (#22577) 1 year ago
mcaptcha Implement FSFE REUSE for golang files (#21840) 2 years ago
metrics include build info in Prometheus metrics (#22819) 1 year ago
migration Fix restore repo bug, clarify the problem of ForeignIndex (#22776) 1 year ago
mirror Implement FSFE REUSE for golang files (#21840) 2 years ago
nosql Implement FSFE REUSE for golang files (#21840) 2 years ago
notification Implement actions (#21937) 1 year ago
options Implement FSFE REUSE for golang files (#21840) 2 years ago
packages Use import of OCI structs (#22765) 1 year ago
paginator Update gitea-vet to check FSFE REUSE (#22004) 2 years ago
password Consume hcaptcha and pwn deps (#22610) 1 year ago
pprof Implement FSFE REUSE for golang files (#21840) 2 years ago
private Implement actions (#21937) 1 year ago
process Improve trace logging for pulls and processes (#22633) 1 year ago
proxy Implement FSFE REUSE for golang files (#21840) 2 years ago
proxyprotocol Implement FSFE REUSE for golang files (#21840) 2 years ago
public Implement FSFE REUSE for golang files (#21840) 2 years ago
queue Correctly handle select on multiple channels in Queues (#22146) 2 years ago
recaptcha Implement FSFE REUSE for golang files (#21840) 2 years ago
references Use correct captured group range when parsing cross-reference (#22672) 1 year ago
regexplru Implement FSFE REUSE for golang files (#21840) 2 years ago
repository Map OIDC groups to Orgs/Teams (#21441) 1 year ago
secret Implement FSFE REUSE for golang files (#21840) 2 years ago
session Update gitea-vet to check FSFE REUSE (#22004) 2 years ago
setting Add Chef package registry (#22554) 1 year ago
sitemap Fix sitemap (#22272) 2 years ago
ssh Implement FSFE REUSE for golang files (#21840) 2 years ago
storage Implement actions (#21937) 1 year ago
structs Use link in UI which returned a relative url but not html_url which contains an absolute url (#21986) 1 year ago
svg Implement FSFE REUSE for golang files (#21840) 2 years ago
sync Implement FSFE REUSE for golang files (#21840) 2 years ago
system Implement FSFE REUSE for golang files (#21840) 2 years ago
templates Implement actions (#21937) 1 year ago
test refactor some functions to support ctx as first parameter (#21878) 2 years ago
timeutil Check for zero time instant in `TimeStamp.IsZero()` (#22171) 2 years ago
translation Implement FSFE REUSE for golang files (#21840) 2 years ago
turnstile Add new captcha: cloudflare turnstile (#22369) 1 year ago
typesniffer Implement FSFE REUSE for golang files (#21840) 2 years ago
updatechecker Implement FSFE REUSE for golang files (#21840) 2 years ago
upload Implement FSFE REUSE for golang files (#21840) 2 years ago
uri Implement FSFE REUSE for golang files (#21840) 2 years ago
user Implement FSFE REUSE for golang files (#21840) 2 years ago
util Add Chef package registry (#22554) 1 year ago
validation Map OIDC groups to Orgs/Teams (#21441) 1 year ago
watcher Implement FSFE REUSE for golang files (#21840) 2 years ago
web Map OIDC groups to Orgs/Teams (#21441) 1 year ago
webhook Restructure `webhook` module (#22256) 2 years ago