diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 27ec43b..1b1093a 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -1,65 +1,60 @@ name: Go -on: [push, pull_request] +on: + push: + branches: + - main + - pmm-* + tags: + - v[0-9]+.[0-9]+.[0-9]+* + + pull_request: jobs: test: name: Test strategy: matrix: - go-version: - - 1.19 proxysql-image: - percona/proxysql:1.2.1 - perconalab/proxysql:1.3.6 - include: - - go-version: tip - os: ubuntu-latest - may-fail: true runs-on: ubuntu-latest 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: Build - run: make build - - name: Run checks - run: | - go build -modfile=go.mod -o bin/golangci-lint github.com/golangci/golangci-lint/cmd/golangci-lint - go build -modfile=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 - make format - git diff --exit-code - make build - - name: Run Tests - env: - PROXYSQL_IMAGE: ${{ matrix.proxysql-image }} - run: | - docker --version - docker-compose --version - docker-compose up -d - make testall - - name: Run debug commands on failure - if: ${{ failure() }} - run: | - env - go version - go env - pwd - git status + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version-file: ${{ github.workspace }}/go.mod + + - name: Build + run: make build + + - name: Run checks + run: | + go build -modfile=go.mod -o bin/golangci-lint github.com/golangci/golangci-lint/cmd/golangci-lint + go build -modfile=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 + make format + git diff --exit-code + make build + + - name: Run Tests + env: + PROXYSQL_IMAGE: ${{ matrix.proxysql-image }} + run: | + docker --version + docker-compose --version + docker-compose up -d + make testall + + - name: Run debug commands on failure + if: ${{ failure() }} + run: | + env + go version + go env + pwd + git status diff --git a/Makefile b/Makefile index 3cf38d6..c2f7c42 100644 --- a/Makefile +++ b/Makefile @@ -15,12 +15,12 @@ GO := go FIRST_GOPATH := $(firstword $(subst :, ,$(shell $(GO) env GOPATH))) PROMU := bin/promu -v -pkgs = $(shell $(GO) list ./... | grep -v /vendor/) PREFIX ?= $(shell pwd) BIN_DIR ?= $(shell pwd) DOCKER_IMAGE_NAME ?= proxysql-exporter DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD)) +PKGS ?= ./... # Race detector is only supported on amd64. RACE := $(shell test $$(go env GOARCH) != "amd64" || (echo "-race")) @@ -33,23 +33,23 @@ all: format build test style: @echo ">> checking code style" - @! gofmt -d $(shell find . -path ./vendor -prune -o -name '*.go' -print) | grep '^' + @! gofmt -d $(shell find . -path ./... -prune -o -name '*.go' -print) | grep '^' test: @echo ">> running tests" - @$(GO) test -v -short $(RACE) -coverprofile coverage.txt $(pkgs) + @$(GO) test -v -short $(RACE) -coverprofile coverage.txt $(PKGS) testall: @echo ">> running all tests" - @$(GO) test -v $(RACE) -coverprofile coverage.txt $(pkgs) + @$(GO) test -v $(RACE) -coverprofile coverage.txt $(PKGS) format: @echo ">> formatting code" - @$(GO) fmt $(pkgs) + @$(GO) fmt $(PKGS) vet: @echo ">> vetting code" - @$(GO) vet $(pkgs) + @$(GO) vet $(PKGS) build: promu @echo ">> building binaries" diff --git a/NOTICE b/NOTICE index 603f0e3..6f3fcab 100644 --- a/NOTICE +++ b/NOTICE @@ -1,2 +1,2 @@ Percona ProxySQL Exporter. -Copyright 2016-2017 Percona LLC +Copyright 2023 Percona LLC diff --git a/README.md b/README.md index d94e701..3ddf28f 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,11 @@ # Percona ProxySQL Exporter -[![Build Status](https://travis-ci.com/percona/proxysql_exporter.svg?branch=master)](https://travis-ci.com/percona/proxysql_exporter) +[![Build Status](https://github.com/percona/proxysql_exporter/actions/workflows/go.yml/badge.svg?branch=main)](https://github.com/percona/proxysql_exporter/actions/workflows/go.yml) [![Go Report Card](https://goreportcard.com/badge/github.com/percona/proxysql_exporter)](https://goreportcard.com/report/github.com/percona/proxysql_exporter) [![CLA assistant](https://cla-assistant.percona.com/readme/badge/percona/proxysql_exporter)](https://cla-assistant.percona.com/percona/proxysql_exporter) Prometheus exporter for [ProxySQL](https://github.com/sysown/proxysql) performance data. Supported versions: 1.2 and 1.3. - ## Building and running ### Building @@ -15,7 +14,6 @@ Supported versions: 1.2 and 1.3. make ``` - ### Running The MySQL server's data source name must be set via the `DATA_SOURCE_NAME` environment variable. The format of this @@ -32,36 +30,32 @@ export HTTP_AUTH='user:password' Note, using `stats` user requires ProxySQL 1.2.4 or higher. Otherwise, use `admin` user. - ### Collector Flags -Name | Description --------------------------------------------|------------ -`collect.detailed.stats_mysql_processlist` | Collect detailed connection list from stats_mysql_processlist. -`collect.mysql_connection_list` | Collect connection list from stats_mysql_processlist. (default true) -`collect.mysql_connection_pool` | Collect from stats_mysql_connection_pool. (default true) -`collect.mysql_status` | Collect from stats_mysql_global (SHOW MYSQL STATUS). (default true) -`collect.runtime_mysql_servers` | Collect from runtime_mysql_servers - need admin credentials. (default false) -`collect.stats_memory_metrics` | Collect memory metrics from stats_memory_metrics. - +| Name | Description | +| ------------------------------------------ | ---------------------------------------------------------------------------- | +| `collect.detailed.stats_mysql_processlist` | Collect detailed connection list from stats_mysql_processlist. | +| `collect.mysql_connection_list` | Collect connection list from stats_mysql_processlist. (default true) | +| `collect.mysql_connection_pool` | Collect from stats_mysql_connection_pool. (default true) | +| `collect.mysql_status` | Collect from stats_mysql_global (SHOW MYSQL STATUS). (default true) | +| `collect.runtime_mysql_servers` | Collect from runtime_mysql_servers - need admin credentials. (default false) | +| `collect.stats_memory_metrics` | Collect memory metrics from stats_memory_metrics. | ### General Flags -Name | Description ----------------------|------------ -`version` | Print version information and exit. -`web.auth-file` | Path to YAML file with server_user, server_password keys for HTTP Basic authentication (overrides HTTP_AUTH environment variable). -`web.listen-address` | Address to listen on for web interface and telemetry. (default ":42004") -`web.ssl-cert-file` | Path to SSL certificate file. -`web.ssl-key-file` | Path to SSL key file. -`web.telemetry-path` | Path under which to expose metrics. (default "/metrics") - +| Name | Description | +| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | +| `version` | Print version information and exit. | +| `web.auth-file` | Path to YAML file with server_user, server_password keys for HTTP Basic authentication (overrides HTTP_AUTH environment variable). | +| `web.listen-address` | Address to listen on for web interface and telemetry. (default ":42004") | +| `web.ssl-cert-file` | Path to SSL certificate file. | +| `web.ssl-key-file` | Path to SSL key file. | +| `web.telemetry-path` | Path under which to expose metrics. (default "/metrics") | ## Visualizing There is a Grafana dashboard for ProxySQL available as a part of [PMM](https://www.percona.com/doc/percona-monitoring-and-management/2.x/index.html) project, you can see the demo [here](https://pmmdemo.percona.com/graph/d/proxysql-instance-summary/proxysql-instance-summary). - ## Submitting Bug Reports If you find a bug in Percona ProxySQL Exporter or one of the related projects, you should submit a report to that project's [JIRA](https://jira.percona.com) issue tracker. @@ -72,13 +66,13 @@ If there is no existing report, submit a report following these steps: 1. [Sign in to Percona JIRA.](https://jira.percona.com/login.jsp) You will need to create an account if you do not have one. 2. [Go to the Create Issue screen and select the relevant project.](https://jira.percona.com/secure/CreateIssueDetails!init.jspa?pid=11600&issuetype=1&priority=3&components=11601) -3. Fill in the fields of Summary, Description, Steps To Reproduce, and Affects Version to the best you can. If the bug corresponds to a crash, attach the stack trace from the logs. +3. Fill in the fields of Summary, Description, Steps To Reproduce, and Affects Version to the best you can. If the bug is due to a crash, attach the stack trace from the logs. -An excellent resource is [Elika Etemad's article on filing good bug reports.](http://fantasai.inkedblade.net/style/talks/filing-good-bugs/). +An excellent resource is [Elika Etemad's article on filing good bug reports.](https://fantasai.inkedblade.net/style/talks/filing-good-bugs/). As a general rule of thumb, please try to create bug reports that are: -- *Reproducible.* Include steps to reproduce the problem. -- *Specific.* Include as much detail as possible: which version, what environment, etc. -- *Unique.* Do not duplicate existing tickets. -- *Scoped to a Single Bug.* One bug per report. +- _Reproducible._ Include steps to reproduce the problem. +- _Specific._ Include as much detail as possible: which version, what environment, etc. +- _Unique._ Do not duplicate existing tickets. +- _Scoped to a Single Bug._ One bug per report. diff --git a/VERSION b/VERSION index 9084fa2..45a1b3f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.1.0 +1.1.2 diff --git a/go.mod b/go.mod index fc5b787..d1757d1 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/percona/proxysql_exporter -go 1.19 +go 1.20 require ( github.com/go-kit/log v0.2.1