Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7199257

Browse files
tshcherbanSuperQprombotgodbersysadmind
authoredOct 12, 2022
PMM-10820 exporter update (#76)
* Update build * Update to Go 1.18. * Update minimum Go version to 1.17. * Update Go modules for 1.17 format. * Bump Go modules * Enable dependabot. * Update Prometheus common files. * Fixup yamllint. Signed-off-by: SuperQ <[email protected]> * Update common Prometheus files Signed-off-by: prombot <[email protected]> * Update common Prometheus files (prometheus-community#650) Signed-off-by: prombot <[email protected]> * Update common Prometheus files Signed-off-by: prombot <[email protected]> * Update readme to include Postgres 14 support It looks like postgres 14.1 was added to CI here: prometheus-community@fcb2535 See also: prometheus-community#651 (comment) Signed-off-by: Austin Godber <[email protected]> * Bump github.com/prometheus/common from 0.34.0 to 0.35.0 Bumps [github.com/prometheus/common](https://github.com/prometheus/common) from 0.34.0 to 0.35.0. - [Release notes](https://github.com/prometheus/common/releases) - [Commits](prometheus/common@v0.34.0...v0.35.0) --- updated-dependencies: - dependency-name: github.com/prometheus/common dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * Release v0.11.0 NOTE: pg_stat_bgwriter counter metrics had the `_total` suffix added prometheus-community#556 * [CHANGE] refactor pg_stat_bgwriter metrics into standalone collector prometheus-community#556 * [FEATURE] Add pg_database collector prometheus-community#613 * [ENHANCEMENT] Add pg_database_size_bytes metric prometheus-community#613 * [BUGFIX] Avoid parsing error from bogus Azure Flexible Server custom GUC prometheus-community#587 * [BUGFIX] Fix pg_stat_archiver error in 9.4 and earlier. prometheus-community#599 * [BUGFIX] Sanitize setting values because of Aurora irregularity prometheus-community#620 Signed-off-by: SuperQ <[email protected]> * fix for exporter issue 633 fix for exporter issue 633: prometheus-community#633 "Scan error on column index 2, name \"checkpoint_write_time\": converting driver.Value type float64 (\"6.594096e+06\") to a int: invalid syntax prometheus-community#633" Signed-off-by: bravosierrasierra <[email protected]> * Fix checkpoint_sync_time value type Error: sql: Scan error on column index 3, name \"checkpoint_sync_time\": converting driver.Value type float64 (\"1.876469e+06\") to a int: invalid syntax See also: prometheus-community#633 prometheus-community#666 Signed-off-by: Nicolas Rodriguez <[email protected]> * Release 0.11.1 * [BUGFIX] Fix checkpoint_write_time value type prometheus-community#666 * [BUGFIX] Fix checkpoint_sync_time value type prometheus-community#667 Signed-off-by: SuperQ <[email protected]> * PMM-10820 missing metric restore * PMM-10820 missing metric drop * PMM-10820 merge fix * PMM-10820 PR review fix Signed-off-by: SuperQ <[email protected]> Signed-off-by: prombot <[email protected]> Signed-off-by: Austin Godber <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: bravosierrasierra <[email protected]> Signed-off-by: Nicolas Rodriguez <[email protected]> Co-authored-by: SuperQ <[email protected]> Co-authored-by: prombot <[email protected]> Co-authored-by: Austin Godber <[email protected]> Co-authored-by: Joe Adams <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: bravosierrasierra <[email protected]> Co-authored-by: Nicolas Rodriguez <[email protected]>
1 parent 80bb494 commit 7199257

File tree

16 files changed

+251
-104
lines changed

16 files changed

+251
-104
lines changed
 

‎.circleci/config.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
---
2+
version: 2.1
3+
4+
orbs:
5+
prometheus: prometheus/prometheus@0.16.0
6+
7+
executors:
8+
# This must match .promu.yml.
9+
golang:
10+
docker:
11+
- image: cimg/go:1.18
12+
13+
jobs:
14+
test:
15+
executor: golang
16+
17+
steps:
18+
- prometheus/setup_environment
19+
- run: make
20+
- prometheus/store_artifact:
21+
file: postgres_exporter
22+
23+
integration:
24+
docker:
25+
- image: cimg/go:1.18
26+
- image: << parameters.postgres_image >>
27+
environment:
28+
POSTGRES_DB: circle_test
29+
POSTGRES_USER: postgres
30+
POSTGRES_PASSWORD: test
31+
32+
parameters:
33+
postgres_image:
34+
type: string
35+
36+
environment:
37+
DATA_SOURCE_NAME: 'postgresql://postgres:test@localhost:5432/circle_test?sslmode=disable'
38+
GOOPTS: '-v -tags integration'
39+
40+
steps:
41+
- checkout
42+
- setup_remote_docker
43+
- run: docker version
44+
- run: make build
45+
- run: make test
46+
47+
workflows:
48+
version: 2
49+
postgres_exporter:
50+
jobs:
51+
- test:
52+
filters:
53+
tags:
54+
only: /.*/
55+
- integration:
56+
matrix:
57+
parameters:
58+
postgres_image:
59+
- circleci/postgres:10
60+
- circleci/postgres:11
61+
- circleci/postgres:12
62+
- circleci/postgres:13
63+
- cimg/postgres:14.1
64+
- prometheus/build:
65+
name: build
66+
parallelism: 3
67+
promu_opts: "-p linux/amd64 -p windows/amd64 -p linux/arm64 -p darwin/amd64 -p darwin/arm64 -p linux/386"
68+
filters:
69+
tags:
70+
ignore: /^v.*/
71+
branches:
72+
ignore: /^(main|master|release-.*|.*build-all.*)$/
73+
- prometheus/build:
74+
name: build_all
75+
parallelism: 12
76+
filters:
77+
branches:
78+
only: /^(main|master|release-.*|.*build-all.*)$/
79+
tags:
80+
only: /^v.*/
81+
- prometheus/publish_master:
82+
context: org-context
83+
docker_hub_organization: prometheuscommunity
84+
quay_io_organization: prometheuscommunity
85+
requires:
86+
- test
87+
- build_all
88+
filters:
89+
branches:
90+
only: master
91+
- prometheus/publish_release:
92+
context: org-context
93+
docker_hub_organization: prometheuscommunity
94+
quay_io_organization: prometheuscommunity
95+
requires:
96+
- test
97+
- build_all
98+
filters:
99+
tags:
100+
only: /^v.*/
101+
branches:
102+
ignore: /.*/

‎.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "gomod"
4+
directory: "/"
5+
schedule:
6+
interval: "monthly"

‎.github/workflows/golangci-lint.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: golangci-lint
2+
on:
3+
push:
4+
paths:
5+
- "go.sum"
6+
- "go.mod"
7+
- "**.go"
8+
- "scripts/errcheck_excludes.txt"
9+
- ".github/workflows/golangci-lint.yml"
10+
- ".golangci.yml"
11+
pull_request:
12+
13+
jobs:
14+
golangci:
15+
name: lint
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v3
20+
- name: install Go
21+
uses: actions/setup-go@v2
22+
with:
23+
go-version: 1.18.x
24+
- name: Install snmp_exporter/generator dependencies
25+
run: sudo apt-get update && sudo apt-get -y install libsnmp-dev
26+
if: github.repository == 'prometheus/snmp_exporter'
27+
- name: Lint
28+
uses: golangci/golangci-lint-action@v3.2.0
29+
with:
30+
version: v1.45.2

‎.promu.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
go:
22
# This must match .circle/config.yml.
3-
version: 1.17
3+
version: 1.18
44
repository:
55
path: github.com/prometheus-community/postgres_exporter
66
build:

‎.yamllint

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
extends: default
3+
4+
rules:
5+
braces:
6+
max-spaces-inside: 1
7+
level: error
8+
brackets:
9+
max-spaces-inside: 1
10+
level: error
11+
commas: disable
12+
comments: disable
13+
comments-indentation: disable
14+
document-start: disable
15+
indentation:
16+
spaces: consistent
17+
indent-sequences: consistent
18+
key-duplicates:
19+
ignore: |
20+
config/testdata/section_key_dup.bad.yml
21+
line-length: disable
22+
truthy:
23+
ignore: |
24+
.github/workflows/codeql-analysis.yml
25+
.github/workflows/funcbench.yml
26+
.github/workflows/fuzzing.yml
27+
.github/workflows/prombench.yml
28+
.github/workflows/golangci-lint.yml

‎CHANGELOG.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
11
## master / unreleased
22

3-
* [CHANGE] pg_stat_bgwriter counter metrics had the `_total` suffix added #556
3+
## 0.11.1 / 2022-08-01
4+
5+
* [BUGFIX] Fix checkpoint_write_time value type #666
6+
* [BUGFIX] Fix checkpoint_sync_time value type #667
7+
8+
## 0.11.0 / 2022-07-28
9+
10+
NOTE: pg_stat_bgwriter counter metrics had the `_total` suffix added #556
11+
12+
* [CHANGE] refactor pg_stat_bgwriter metrics into standalone collector #556
13+
* [FEATURE] Add pg_database collector #613
414
* [ENHANCEMENT] Add pg_database_size_bytes metric #613
15+
* [BUGFIX] Avoid parsing error from bogus Azure Flexible Server custom GUC #587
16+
* [BUGFIX] Fix pg_stat_archiver error in 9.4 and earlier. #599
17+
* [BUGFIX] Sanitize setting values because of Aurora irregularity #620
518

619
## 0.10.1 / 2022-01-14
720

‎CODE_OF_CONDUCT.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
## Prometheus Community Code of Conduct
1+
# Prometheus Community Code of Conduct
22

3-
Prometheus follows the [CNCF Code of Conduct](https://github.com/cncf/foundation/blob/master/code-of-conduct.md).
3+
Prometheus follows the [CNCF Code of Conduct](https://github.com/cncf/foundation/blob/main/code-of-conduct.md).

‎Makefile.common

Lines changed: 12 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -36,29 +36,6 @@ GO_VERSION ?= $(shell $(GO) version)
3636
GO_VERSION_NUMBER ?= $(word 3, $(GO_VERSION))
3737
PRE_GO_111 ?= $(shell echo $(GO_VERSION_NUMBER) | grep -E 'go1\.(10|[0-9])\.')
3838

39-
GOVENDOR :=
40-
GO111MODULE :=
41-
ifeq (, $(PRE_GO_111))
42-
ifneq (,$(wildcard go.mod))
43-
# Enforce Go modules support just in case the directory is inside GOPATH (and for Travis CI).
44-
GO111MODULE := on
45-
46-
ifneq (,$(wildcard vendor))
47-
# Always use the local vendor/ directory to satisfy the dependencies.
48-
GOOPTS := $(GOOPTS) -mod=vendor
49-
endif
50-
endif
51-
else
52-
ifneq (,$(wildcard go.mod))
53-
ifneq (,$(wildcard vendor))
54-
$(warning This repository requires Go >= 1.11 because of Go modules)
55-
$(warning Some recipes may not work as expected as the current Go runtime is '$(GO_VERSION_NUMBER)')
56-
endif
57-
else
58-
# This repository isn't using Go modules (yet).
59-
GOVENDOR := $(FIRST_GOPATH)/bin/govendor
60-
endif
61-
endif
6239
PROMU := $(FIRST_GOPATH)/bin/promu
6340
pkgs = ./...
6441

@@ -83,7 +60,7 @@ PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_
8360

8461
GOLANGCI_LINT :=
8562
GOLANGCI_LINT_OPTS ?=
86-
GOLANGCI_LINT_VERSION ?= v1.42.0
63+
GOLANGCI_LINT_VERSION ?= v1.45.2
8764
# golangci-lint only supports linux, darwin and windows platforms on i386/amd64.
8865
# windows isn't included here because of the path separator being different.
8966
ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin))
@@ -139,87 +116,63 @@ common-style:
139116
.PHONY: common-deps
140117
common-deps:
141118
@echo ">> getting dependencies"
142-
ifdef GO111MODULE
143-
GO111MODULE=$(GO111MODULE) $(GO) mod download
144-
else
145-
$(GO) get $(GOOPTS) -t ./...
146-
endif
119+
$(GO) mod download
147120

148121
.PHONY: update-go-deps
149122
update-go-deps:
150123
@echo ">> updating Go dependencies"
151124
@for m in $$($(GO) list -mod=readonly -m -f '{{ if and (not .Indirect) (not .Main)}}{{.Path}}{{end}}' all); do \
152125
$(GO) get -d $$m; \
153126
done
154-
GO111MODULE=$(GO111MODULE) $(GO) mod tidy
155-
ifneq (,$(wildcard vendor))
156-
GO111MODULE=$(GO111MODULE) $(GO) mod vendor
157-
endif
127+
$(GO) mod tidy
158128

159129
.PHONY: common-test-short
160130
common-test-short: $(GOTEST_DIR)
161131
@echo ">> running short tests"
162-
GO111MODULE=$(GO111MODULE) $(GOTEST) -short $(GOOPTS) $(pkgs)
132+
$(GOTEST) -short $(GOOPTS) $(pkgs)
163133

164134
.PHONY: common-test
165135
common-test: $(GOTEST_DIR)
166136
@echo ">> running all tests"
167-
GO111MODULE=$(GO111MODULE) $(GOTEST) $(test-flags) $(GOOPTS) $(pkgs)
137+
$(GOTEST) $(test-flags) $(GOOPTS) $(pkgs)
168138

169139
$(GOTEST_DIR):
170140
@mkdir -p $@
171141

172142
.PHONY: common-format
173143
common-format:
174144
@echo ">> formatting code"
175-
GO111MODULE=$(GO111MODULE) $(GO) fmt $(pkgs)
145+
$(GO) fmt $(pkgs)
176146

177147
.PHONY: common-vet
178148
common-vet:
179149
@echo ">> vetting code"
180-
GO111MODULE=$(GO111MODULE) $(GO) vet $(GOOPTS) $(pkgs)
150+
$(GO) vet $(GOOPTS) $(pkgs)
181151

182152
.PHONY: common-lint
183153
common-lint: $(GOLANGCI_LINT)
184154
ifdef GOLANGCI_LINT
185155
@echo ">> running golangci-lint"
186-
ifdef GO111MODULE
187156
# 'go list' needs to be executed before staticcheck to prepopulate the modules cache.
188157
# Otherwise staticcheck might fail randomly for some reason not yet explained.
189-
GO111MODULE=$(GO111MODULE) $(GO) list -e -compiled -test=true -export=false -deps=true -find=false -tags= -- ./... > /dev/null
190-
GO111MODULE=$(GO111MODULE) $(GOLANGCI_LINT) run $(GOLANGCI_LINT_OPTS) $(pkgs)
191-
else
192-
$(GOLANGCI_LINT) run $(pkgs)
193-
endif
158+
$(GO) list -e -compiled -test=true -export=false -deps=true -find=false -tags= -- ./... > /dev/null
159+
$(GOLANGCI_LINT) run $(GOLANGCI_LINT_OPTS) $(pkgs)
194160
endif
195161

196162
# For backward-compatibility.
197163
.PHONY: common-staticcheck
198164
common-staticcheck: lint
199165

200166
.PHONY: common-unused
201-
common-unused: $(GOVENDOR)
202-
ifdef GOVENDOR
203-
@echo ">> running check for unused packages"
204-
@$(GOVENDOR) list +unused | grep . && exit 1 || echo 'No unused packages'
205-
else
206-
ifdef GO111MODULE
167+
common-unused:
207168
@echo ">> running check for unused/missing packages in go.mod"
208-
GO111MODULE=$(GO111MODULE) $(GO) mod tidy
209-
ifeq (,$(wildcard vendor))
169+
$(GO) mod tidy
210170
@git diff --exit-code -- go.sum go.mod
211-
else
212-
@echo ">> running check for unused packages in vendor/"
213-
GO111MODULE=$(GO111MODULE) $(GO) mod vendor
214-
@git diff --exit-code -- go.sum go.mod vendor/
215-
endif
216-
endif
217-
endif
218171

219172
.PHONY: common-build
220173
common-build: promu
221174
@echo ">> building binaries"
222-
GO111MODULE=$(GO111MODULE) $(PROMU) build --prefix $(PREFIX) $(PROMU_BINARIES)
175+
$(PROMU) build --prefix $(PREFIX) $(PROMU_BINARIES)
223176

224177
.PHONY: common-tarball
225178
common-tarball: promu
@@ -275,12 +228,6 @@ $(GOLANGCI_LINT):
275228
| sh -s -- -b $(FIRST_GOPATH)/bin $(GOLANGCI_LINT_VERSION)
276229
endif
277230

278-
ifdef GOVENDOR
279-
.PHONY: $(GOVENDOR)
280-
$(GOVENDOR):
281-
GOOS= GOARCH= $(GO) get -u github.com/kardianos/govendor
282-
endif
283-
284231
.PHONY: precheck
285232
precheck::
286233

‎README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
Prometheus exporter for PostgreSQL server metrics.
99

10-
CI Tested PostgreSQL versions: `9.4`, `9.5`, `9.6`, `10`, `11`, `12`, `13`
10+
CI Tested PostgreSQL versions: `9.4`, `9.5`, `9.6`, `10`, `11`, `12`, `13`, `14`
1111

1212
## Quick Start
1313
This package is available for Docker:

‎SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
The Prometheus security policy, including how to report vulnerabilities, can be
44
found here:
55

6-
https://prometheus.io/docs/operating/security/
6+
<https://prometheus.io/docs/operating/security/>

‎VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.10.1
1+
0.11.1

‎cmd/postgres_exporter/tests/docker-postgres-replication/docker-compose.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
---
22
version: '2'
33

44
services:
@@ -11,9 +11,9 @@ services:
1111
POSTGRES_PASSWORD: 'postgres'
1212
PGDATA: '/var/lib/postgresql/data/pgdata'
1313
volumes:
14-
- '/var/lib/postgresql/data'
14+
- '/var/lib/postgresql/data'
1515
expose:
16-
- '5432'
16+
- '5432'
1717

1818
pg-slave:
1919
build: '.'
@@ -25,8 +25,8 @@ services:
2525
PGDATA: '/var/lib/postgresql/data/pgdata'
2626
REPLICATE_FROM: 'pg-master'
2727
volumes:
28-
- '/var/lib/postgresql/data'
28+
- '/var/lib/postgresql/data'
2929
expose:
30-
- '5432'
30+
- '5432'
3131
links:
32-
- 'pg-master'
32+
- 'pg-master'

‎collector/pg_stat_bgwriter.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ func (PGStatBGWriterCollector) Update(ctx context.Context, server *server, ch ch
192192

193193
var cpt int
194194
var cpr int
195-
var cpwt int
196-
var cpst int
195+
var cpwt float64
196+
var cpst float64
197197
var bcp int
198198
var bc int
199199
var mwc int

‎go.mod

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ go 1.17
44

55
require (
66
github.com/blang/semver v3.5.1+incompatible
7-
github.com/go-kit/log v0.2.0
8-
github.com/lib/pq v1.10.4
7+
github.com/go-kit/log v0.2.1
8+
github.com/lib/pq v1.10.6
99
github.com/montanaflynn/stats v0.6.6
1010
github.com/pkg/errors v0.9.1
11-
github.com/prometheus/client_golang v1.12.1
11+
github.com/prometheus/client_golang v1.12.2
1212
github.com/prometheus/client_model v0.2.0
13-
github.com/prometheus/common v0.32.1
13+
github.com/prometheus/common v0.35.0
1414
github.com/prometheus/exporter-toolkit v0.7.1
1515
github.com/stretchr/testify v1.4.0
1616
github.com/tklauser/go-sysconf v0.3.10
@@ -25,21 +25,24 @@ require (
2525
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d // indirect
2626
github.com/beorn7/perks v1.0.1 // indirect
2727
github.com/cespare/xxhash/v2 v2.1.2 // indirect
28-
github.com/davecgh/go-spew v1.1.1 // indirect
2928
github.com/go-logfmt/logfmt v0.5.1 // indirect
3029
github.com/golang/protobuf v1.5.2 // indirect
3130
github.com/jpillora/backoff v1.0.0 // indirect
3231
github.com/kr/pretty v0.2.1 // indirect
3332
github.com/kr/text v0.1.0 // indirect
3433
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
3534
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
36-
github.com/pmezard/go-difflib v1.0.0 // indirect
3735
github.com/prometheus/procfs v0.7.3 // indirect
38-
github.com/tklauser/numcpus v0.4.0 // indirect
3936
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e // indirect
40-
golang.org/x/net v0.0.0-20210525063256-abc453219eb5 // indirect
41-
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c // indirect
42-
golang.org/x/text v0.3.6 // indirect
37+
golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect
38+
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect
39+
golang.org/x/text v0.3.7 // indirect
4340
google.golang.org/appengine v1.6.6 // indirect
4441
google.golang.org/protobuf v1.26.0 // indirect
4542
)
43+
44+
require (
45+
github.com/davecgh/go-spew v1.1.1 // indirect
46+
github.com/pmezard/go-difflib v1.0.0 // indirect
47+
github.com/tklauser/numcpus v0.4.0 // indirect
48+
)

‎go.sum

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2
6868
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
6969
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
7070
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
71-
github.com/go-kit/log v0.2.0 h1:7i2K3eKTos3Vc0enKCfnVcgHh2olr/MyfboYq7cAcFw=
7271
github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0=
72+
github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU=
73+
github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0=
7374
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
7475
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
7576
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
@@ -153,8 +154,8 @@ github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfn
153154
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
154155
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
155156
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
156-
github.com/lib/pq v1.10.4 h1:SO9z7FRPzA03QhHKJrH5BXA6HU1rS4V2nIVrrNC1iYk=
157-
github.com/lib/pq v1.10.4/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
157+
github.com/lib/pq v1.10.6 h1:jbk+ZieJ0D7EVGJYpL9QTz7/YW6UHbmdnZWYyK5cdBs=
158+
github.com/lib/pq v1.10.6/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
158159
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
159160
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
160161
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
@@ -177,8 +178,9 @@ github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXP
177178
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
178179
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
179180
github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
180-
github.com/prometheus/client_golang v1.12.1 h1:ZiaPsmm9uiBeaSMRznKsCDNtPCS0T3JVDGF+06gjBzk=
181181
github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY=
182+
github.com/prometheus/client_golang v1.12.2 h1:51L9cDoUHVrXx4zWYlcLQIZ+d+VXHgqnYKkIuq4g/34=
183+
github.com/prometheus/client_golang v1.12.2/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY=
182184
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
183185
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
184186
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -188,8 +190,9 @@ github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8
188190
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
189191
github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc=
190192
github.com/prometheus/common v0.29.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls=
191-
github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4=
192193
github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls=
194+
github.com/prometheus/common v0.35.0 h1:Eyr+Pw2VymWejHqCugNaQXkAi6KayVNxaHeu6khmFBE=
195+
github.com/prometheus/common v0.35.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA=
193196
github.com/prometheus/exporter-toolkit v0.7.1 h1:c6RXaK8xBVercEeUQ4tRNL8UGWzDHfvj9dseo1FcK1Y=
194197
github.com/prometheus/exporter-toolkit v0.7.1/go.mod h1:ZUBIj498ePooX9t/2xtDjeQYwvRpiPP2lh5u4iblj2g=
195198
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
@@ -287,15 +290,18 @@ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R
287290
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
288291
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
289292
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
290-
golang.org/x/net v0.0.0-20210525063256-abc453219eb5 h1:wjuX4b5yYQnEQHzd+CBcrcC6OVR2J1CN6mUy0oSxIPo=
291293
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
294+
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
295+
golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3KG69V2UGQWPBxujDmc=
296+
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
292297
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
293298
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
294299
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
295300
golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
296301
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
297-
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c h1:pkQiBZBvdos9qq4wBAHqlzuZHEXo07pqV06ef90u1WI=
298302
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
303+
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b h1:clP8eMhB30EHdc0bd2Twtq6kgU7yl5ub2cQLSdrv1Dg=
304+
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc=
299305
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
300306
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
301307
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -341,17 +347,20 @@ golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7w
341347
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
342348
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
343349
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
350+
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
344351
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
345352
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27 h1:XDXtA5hveEEV8JB2l7nhMTp3t3cHp9ZpwcdjqyEWLlo=
346353
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
347354
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
355+
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
348356
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
349357
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
350358
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
351359
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
352360
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
353-
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
354361
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
362+
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
363+
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
355364
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
356365
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
357366
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=

‎percona_tests/metrics_test.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ var printExtraMetrics = flag.Bool("extraMetrics", false, "")
1616
var printMultipleLabels = flag.Bool("multipleLabels", false, "")
1717
var endpointFlag = flag.String("endpoint", "", "")
1818

19+
const highResolutionEndpoint = "metrics?collect%5B%5D=custom_query.hr&collect%5B%5D=exporter&collect%5B%5D=standard.go&collect%5B%5D=standard.process"
20+
const medResolutionEndpoint = "metrics?collect%5B%5D=custom_query.mr"
21+
const lowResolutionEndpoint = "metrics?collect%5B%5D=custom_query.lr"
22+
23+
// that metric is disabled by default in new exporters, so will trigger test
24+
// however we don't use it at all in our dashboards, so for now - safe to skip it
25+
const skipMetricName = "go_memstats_gc_cpu_fraction"
26+
1927
type Metric struct {
2028
name string
2129
labelsRawStr string
@@ -118,10 +126,6 @@ func TestDumpMetrics(t *testing.T) {
118126
dumpMetricsInfo(oldMetricsCollection, newMetricsCollection)
119127
}
120128

121-
const highResolutionEndpoint = "metrics?collect%5B%5D=custom_query.hr&collect%5B%5D=exporter&collect%5B%5D=standard.go&collect%5B%5D=standard.process"
122-
const medResolutionEndpoint = "metrics?collect%5B%5D=custom_query.mr"
123-
const lowResolutionEndpoint = "metrics?collect%5B%5D=custom_query.lr"
124-
125129
func TestResolutionsMetricDuplicates(t *testing.T) {
126130
if !getBool(doRun) {
127131
t.Skip("For manual runs only through make")
@@ -219,7 +223,8 @@ func testResolution(t *testing.T, resolutionEp, resolutionName string) {
219223
missingLabelsCount := 0
220224
missingLabels := ""
221225
for _, oldMetric := range oldMetricsCollection.MetricsData {
222-
if oldMetric.name == "" || strings.HasPrefix(oldMetric.name, "# ") {
226+
// skip empty lines, comments and redundant metrics
227+
if oldMetric.name == "" || strings.HasPrefix(oldMetric.name, "# ") || oldMetric.name == skipMetricName {
223228
continue
224229
}
225230

@@ -253,7 +258,7 @@ func testResolution(t *testing.T, resolutionEp, resolutionName string) {
253258
}
254259

255260
if missingCount > 0 {
256-
t.Errorf("%d metrics are missing in new exporter for %s resolution:\n%s", missingCount, resolutionName, missingMetrics)
261+
t.Errorf("%d metric(s) are missing in new exporter for %s resolution:\n%s", missingCount, resolutionName, missingMetrics)
257262
}
258263

259264
if missingLabelsCount > 0 {
@@ -326,6 +331,10 @@ func testForMissingMetricsLabels(oldMetricsCollection, newMetricsCollection Metr
326331
func testForMissingMetrics(oldMetricsCollection, newMetricsCollection MetricsCollection) (bool, string) {
327332
missingMetrics := make([]string, 0)
328333
for metricName := range oldMetricsCollection.LabelsByMetric {
334+
if metricName == skipMetricName {
335+
continue
336+
}
337+
329338
if _, ok := newMetricsCollection.LabelsByMetric[metricName]; !ok {
330339
missingMetrics = append(missingMetrics, metricName)
331340
}

0 commit comments

Comments
 (0)
Please sign in to comment.