Skip to content

PMM-7806: add compatibility with percona pg exporter #68

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

Merged
merged 19 commits into from
Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 0 additions & 90 deletions .circleci/config.yml

This file was deleted.

47 changes: 0 additions & 47 deletions .github/ISSUE_TEMPLATE/bug_report.md

This file was deleted.

5 changes: 0 additions & 5 deletions .github/ISSUE_TEMPLATE/config.yml

This file was deleted.

21 changes: 0 additions & 21 deletions .github/ISSUE_TEMPLATE/feature_request.md

This file was deleted.

75 changes: 75 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Go

on:
push:
branches:
- main
tags:
- v[0-9]+.[0-9]+.[0-9]+*
pull_request:

jobs:
test:
name: Test
strategy:
matrix:
go-version:
- 1.17
postgresql-image:
- postgres:10
- postgres:11
- postgres:12
include:
- go-version: tip
os: ubuntu-latest
postgresql-image: postgres:12
may-fail: true
runs-on: ubuntu-latest
# The environment this job references
environment:
name: CI
steps:
- name: Set up Go release
if: matrix.go-version != 'tip'
uses: percona-platform/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Set up Go tip
if: matrix.go-version == 'tip'
env:
# to avoid error due to `go version` accepting -v flag with an argument since 1.15
GOFLAGS: ""
run: |
git clone --depth=1 https://go.googlesource.com/go $HOME/gotip
cd $HOME/gotip/src
./make.bash
echo "GOROOT=$HOME/gotip" >> $GITHUB_ENV
echo "$HOME/gotip/bin" >> $GITHUB_PATH
- name: Checkout code
uses: percona-platform/checkout@v2
- name: Run checks
run: |
go build -modfile=tools/go.mod -o bin/golangci-lint github.com/golangci/golangci-lint/cmd/golangci-lint
go build -modfile=tools/go.mod -o bin/reviewdog github.com/reviewdog/reviewdog/cmd/reviewdog
bin/golangci-lint run -c=.golangci-required.yml --out-format=line-number | env REVIEWDOG_GITHUB_API_TOKEN=${{ secrets.GITHUB_TOKEN }} bin/reviewdog -f=golangci-lint -level=error -reporter=github-pr-check
bin/golangci-lint run -c=.golangci.yml --out-format=line-number | env REVIEWDOG_GITHUB_API_TOKEN=${{ secrets.GITHUB_TOKEN }} bin/reviewdog -f=golangci-lint -level=error -reporter=github-pr-review
Comment on lines +35 to +40
Copy link
Member

Choose a reason for hiding this comment

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

can we extract running checks to a separate job?

Copy link
Author

Choose a reason for hiding this comment

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

I took it from the original, exporter. We can think about some generic actions in scope of other task and PR, what do you think?

Copy link
Member

Choose a reason for hiding this comment

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

could you create a task for it then, please?

Copy link
Author

Choose a reason for hiding this comment

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

Can you please clarify what exactly this ticket should be about? Create shared GHA for checks (ie linters)?

Copy link
Member

Choose a reason for hiding this comment

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

extracting checks to a separate job.

- name: Run Tests
run: |
sudo chown 999:999 testdata/ssl/server/*
sudo chmod 600 testdata/ssl/server/*
docker-compose up -d
make
make test
env:
POSTGRESQL_IMAGE: ${{ matrix.postgresql-image }}
- name: Run debug commands on failure
if: ${{ failure() }}
run: |
env
go version
go env
pwd
git status
docker --version
docker-compose --version
docker-compose logs
5 changes: 3 additions & 2 deletions cmd/postgres_exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ var (
disableDefaultMetrics = kingpin.Flag("disable-default-metrics", "Do not include default metrics.").Default("false").Envar("PG_EXPORTER_DISABLE_DEFAULT_METRICS").Bool()
disableSettingsMetrics = kingpin.Flag("disable-settings-metrics", "Do not include pg_settings metrics.").Default("false").Envar("PG_EXPORTER_DISABLE_SETTINGS_METRICS").Bool()
autoDiscoverDatabases = kingpin.Flag("auto-discover-databases", "Whether to discover the databases on a server dynamically.").Default("false").Envar("PG_EXPORTER_AUTO_DISCOVER_DATABASES").Bool()
queriesPath = kingpin.Flag("extend.query-path", "Path to custom queries to run.").Default("").Envar("PG_EXPORTER_EXTEND_QUERY_PATH").String()
onlyDumpMaps = kingpin.Flag("dumpmaps", "Do not run, simply dump the maps.").Bool()
constantLabelsList = kingpin.Flag("constantLabels", "A list of label=value separated by comma(,).").Default("").Envar("PG_EXPORTER_CONSTANT_LABELS").String()
excludeDatabases = kingpin.Flag("exclude-databases", "A list of databases to remove when autoDiscoverDatabases is enabled").Default("").Envar("PG_EXPORTER_EXCLUDE_DATABASES").String()
Expand Down Expand Up @@ -100,7 +99,6 @@ func main() {
DisableDefaultMetrics(*disableDefaultMetrics),
DisableSettingsMetrics(*disableSettingsMetrics),
AutoDiscoverDatabases(*autoDiscoverDatabases),
WithUserQueriesPath(*queriesPath),
WithConstantLabels(*constantLabelsList),
ExcludeDatabases(*excludeDatabases),
IncludeDatabases(*includeDatabases),
Expand All @@ -115,6 +113,9 @@ func main() {

prometheus.MustRegister(exporter)

cleanup := initializePerconaExporters(dsn, opts)
defer cleanup()

pe, err := collector.NewPostgresCollector(
logger,
dsn,
Expand Down
Loading