1
0
mirror of https://github.com/prometheus-community/postgres_exporter.git synced 2025-07-31 20:44:25 +03:00

Refactor PR #157 to fit the new repository format.

This didn't actually need all that much change, it fits perfectly.
This commit is contained in:
Will Rouesnel
2018-03-06 18:49:00 +11:00
parent 2ab8f10935
commit dfc644214b
2 changed files with 16 additions and 9 deletions

View File

@ -5,12 +5,14 @@ import (
"net/http" "net/http"
"runtime" "runtime"
"gopkg.in/alecthomas/kingpin.v2"
_ "github.com/lib/pq" _ "github.com/lib/pq"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp" "github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/prometheus/common/log" "github.com/prometheus/common/log"
"github.com/wrouesnel/postgres_exporter/collector" "github.com/wrouesnel/postgres_exporter/collector"
"gopkg.in/alecthomas/kingpin.v2"
) )
// Version is set during build to the git describe version // Version is set during build to the git describe version
@ -18,10 +20,13 @@ import (
var Version = "0.0.1" var Version = "0.0.1"
var ( var (
listenAddress = kingpin.Flag("web.listen-address", "Address to listen on for web interface and telemetry.").Default(":9187").OverrideDefaultFromEnvar("PG_EXPORTER_WEB_LISTEN_ADDRESS").String() listenAddress = kingpin.Flag("web.listen-address", "Address to listen on for web interface and telemetry.").
metricPath = kingpin.Flag("web.telemetry-path", "Path under which to expose metrics.").Default("/metrics").OverrideDefaultFromEnvar("PG_EXPORTER_WEB_TELEMETRY_PATH").String() Default(":9187").Envar("PG_EXPORTER_WEB_LISTEN_ADDRESS").String()
queriesPath = kingpin.Flag("extend.query-path", "Path to custom queries to run.").Default("").OverrideDefaultFromEnvar("PG_EXPORTER_EXTEND_QUERY_PATH").String() metricPath = kingpin.Flag("web.telemetry-path", "Path under which to expose metrics.").
onlyDumpMaps = kingpin.Flag("dumpmaps", "Do not run, simply dump the maps.").Bool() Default("/metrics").Envar("PG_EXPORTER_WEB_TELEMETRY_PATH").String()
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()
) )
func main() { func main() {

View File

@ -3,11 +3,13 @@
package collector package collector
import ( import (
. "gopkg.in/check.v1"
"testing" "testing"
"github.com/blang/semver" . "gopkg.in/check.v1"
"os" "os"
"github.com/blang/semver"
) )
// Hook up gocheck into the "go test" runner. // Hook up gocheck into the "go test" runner.
@ -89,11 +91,11 @@ func (s *FunctionalSuite) TestSemanticVersionColumnDiscard(c *C) {
// test read username and password from file // test read username and password from file
func (s *FunctionalSuite) TestEnvironmentSettingWithSecretsFiles(c *C) { func (s *FunctionalSuite) TestEnvironmentSettingWithSecretsFiles(c *C) {
err := os.Setenv("DATA_SOURCE_USER_FILE", "../tests/username_file") err := os.Setenv("DATA_SOURCE_USER_FILE", "../cmd/postgres_exporter/tests/username_file")
c.Assert(err, IsNil) c.Assert(err, IsNil)
defer UnsetEnvironment(c, "DATA_SOURCE_USER_FILE") defer UnsetEnvironment(c, "DATA_SOURCE_USER_FILE")
err = os.Setenv("DATA_SOURCE_PASS_FILE", "../tests/userpass_file") err = os.Setenv("DATA_SOURCE_PASS_FILE", "../cmd/postgres_exporter/tests/userpass_file")
c.Assert(err, IsNil) c.Assert(err, IsNil)
defer UnsetEnvironment(c, "DATA_SOURCE_PASS_FILE") defer UnsetEnvironment(c, "DATA_SOURCE_PASS_FILE")