From 5211415ebe1364d1bc2de2d5fffb89a18a5aefb6 Mon Sep 17 00:00:00 2001 From: Will Rouesnel Date: Sat, 25 Feb 2017 01:08:36 +1100 Subject: [PATCH] Gofmt the code. --- postgres_exporter.go | 20 ++++++++++---------- postgres_exporter_integration_test.go | 12 ++++++------ postgres_exporter_test.go | 12 ++++++------ 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/postgres_exporter.go b/postgres_exporter.go index 2763fa77..3ea75762 100644 --- a/postgres_exporter.go +++ b/postgres_exporter.go @@ -148,7 +148,7 @@ type MetricMap struct { // Metric descriptors for dynamically created metrics. var variableMaps = map[string]map[string]ColumnMapping{ - "pg_runtime_variable": map[string]ColumnMapping{ + "pg_runtime_variable": { "max_connections": {GAUGE, "Sets the maximum number of concurrent connections.", nil, nil}, "max_files_per_process": {GAUGE, "Sets the maximum number of simultaneously open files for each server process.", nil, nil}, "max_function_args": {GAUGE, "Shows the maximum number of function arguments.", nil, nil}, @@ -184,7 +184,7 @@ func dumpMaps() { } var metricMaps = map[string]map[string]ColumnMapping{ - "pg_stat_bgwriter": map[string]ColumnMapping{ + "pg_stat_bgwriter": { "checkpoints_timed": {COUNTER, "Number of scheduled checkpoints that have been performed", nil, nil}, "checkpoints_req": {COUNTER, "Number of requested checkpoints that have been performed", nil, nil}, "checkpoint_write_time": {COUNTER, "Total amount of time that has been spent in the portion of checkpoint processing where files are written to disk, in milliseconds", nil, nil}, @@ -197,7 +197,7 @@ var metricMaps = map[string]map[string]ColumnMapping{ "buffers_alloc": {COUNTER, "Number of buffers allocated", nil, nil}, "stats_reset": {COUNTER, "Time at which these statistics were last reset", nil, nil}, }, - "pg_stat_database": map[string]ColumnMapping{ + "pg_stat_database": { "datid": {LABEL, "OID of a database", nil, nil}, "datname": {LABEL, "Name of this database", nil, nil}, "numbackends": {GAUGE, "Number of backends currently connected to this database. This is the only column in this view that returns a value reflecting current state; all other columns return the accumulated values since the last reset.", nil, nil}, @@ -218,7 +218,7 @@ var metricMaps = map[string]map[string]ColumnMapping{ "blk_write_time": {COUNTER, "Time spent writing data file blocks by backends in this database, in milliseconds", nil, nil}, "stats_reset": {COUNTER, "Time at which these statistics were last reset", nil, nil}, }, - "pg_stat_database_conflicts": map[string]ColumnMapping{ + "pg_stat_database_conflicts": { "datid": {LABEL, "OID of a database", nil, nil}, "datname": {LABEL, "Name of this database", nil, nil}, "confl_tablespace": {COUNTER, "Number of queries in this database that have been canceled due to dropped tablespaces", nil, nil}, @@ -227,12 +227,12 @@ var metricMaps = map[string]map[string]ColumnMapping{ "confl_bufferpin": {COUNTER, "Number of queries in this database that have been canceled due to pinned buffers", nil, nil}, "confl_deadlock": {COUNTER, "Number of queries in this database that have been canceled due to deadlocks", nil, nil}, }, - "pg_locks": map[string]ColumnMapping{ + "pg_locks": { "datname": {LABEL, "Name of this database", nil, nil}, "mode": {LABEL, "Type of Lock", nil, nil}, "count": {GAUGE, "Number of locks", nil, nil}, }, - "pg_stat_replication": map[string]ColumnMapping{ + "pg_stat_replication": { "procpid": {DISCARD, "Process ID of a WAL sender process", nil, semver.MustParseRange("<9.2.0")}, "pid": {DISCARD, "Process ID of a WAL sender process", nil, semver.MustParseRange(">=9.2.0")}, "usesysid": {DISCARD, "OID of the user logged into this WAL sender process", nil, nil}, @@ -263,7 +263,7 @@ var metricMaps = map[string]map[string]ColumnMapping{ "pg_current_xlog_location": {DISCARD, "pg_current_xlog_location", nil, nil}, "pg_xlog_location_diff": {GAUGE, "Lag in bytes between master and slave", nil, semver.MustParseRange(">=9.2.0")}, }, - "pg_stat_activity": map[string]ColumnMapping{ + "pg_stat_activity": { "datname": {LABEL, "Name of this database", nil, nil}, "state": {LABEL, "connection state", nil, semver.MustParseRange(">=9.2.0")}, "count": {GAUGE, "number of connections in this state", nil, nil}, @@ -283,7 +283,7 @@ type OverrideQuery struct { // Overriding queries for namespaces above. // TODO: validate this is a closed set in tests, and there are no overlaps var queryOverrides = map[string][]OverrideQuery{ - "pg_locks": []OverrideQuery{ + "pg_locks": { { semver.MustParseRange(">0.0.0"), `SELECT pg_database.datname,tmp.mode,COALESCE(count,0) as count @@ -307,7 +307,7 @@ var queryOverrides = map[string][]OverrideQuery{ }, }, - "pg_stat_replication": []OverrideQuery{ + "pg_stat_replication": { { semver.MustParseRange(">=9.2.0"), ` @@ -327,7 +327,7 @@ var queryOverrides = map[string][]OverrideQuery{ }, }, - "pg_stat_activity": []OverrideQuery{ + "pg_stat_activity": { // This query only works { semver.MustParseRange(">=9.2.0"), diff --git a/postgres_exporter_integration_test.go b/postgres_exporter_integration_test.go index 1a00dad0..89999cee 100644 --- a/postgres_exporter_integration_test.go +++ b/postgres_exporter_integration_test.go @@ -11,16 +11,16 @@ import ( . "gopkg.in/check.v1" - "github.com/prometheus/client_golang/prometheus" "database/sql" - _ "github.com/lib/pq" "fmt" + _ "github.com/lib/pq" + "github.com/prometheus/client_golang/prometheus" ) // Hook up gocheck into the "go test" runner. func Test(t *testing.T) { TestingT(t) } -type IntegrationSuite struct{ +type IntegrationSuite struct { e *Exporter } @@ -43,7 +43,8 @@ func (s *IntegrationSuite) TestAllNamespacesReturnResults(c *C) { // Setup a dummy channel to consume metrics ch := make(chan prometheus.Metric, 100) go func() { - for _ = range ch {} + for range ch { + } }() // Open a database connection @@ -65,7 +66,6 @@ func (s *IntegrationSuite) TestAllNamespacesReturnResults(c *C) { } } - // This should never happen in our test cases. errMap := queryNamespaceMappings(ch, db, s.e.metricMap, s.e.queryOverrides) if !c.Check(len(errMap), Equals, 0) { @@ -74,4 +74,4 @@ func (s *IntegrationSuite) TestAllNamespacesReturnResults(c *C) { fmt.Println(namespace, ":", err) } } -} \ No newline at end of file +} diff --git a/postgres_exporter_test.go b/postgres_exporter_test.go index 6af757d3..a9294c77 100644 --- a/postgres_exporter_test.go +++ b/postgres_exporter_test.go @@ -3,8 +3,8 @@ package main import ( - "testing" . "gopkg.in/check.v1" + "testing" "github.com/blang/semver" ) @@ -12,7 +12,7 @@ import ( // Hook up gocheck into the "go test" runner. func Test(t *testing.T) { TestingT(t) } -type FunctionalSuite struct{ +type FunctionalSuite struct { e *Exporter } @@ -24,9 +24,9 @@ func (s *FunctionalSuite) SetUpSuite(c *C) { func (s *FunctionalSuite) TestSemanticVersionColumnDiscard(c *C) { testMetricMap := map[string]map[string]ColumnMapping{ - "test_namespace" : map[string]ColumnMapping{ - "metric_which_stays" : {COUNTER, "This metric should not be eliminated", nil, nil}, - "metric_which_discards" : {COUNTER, "This metric should be forced to DISCARD", nil, nil}, + "test_namespace": { + "metric_which_stays": {COUNTER, "This metric should not be eliminated", nil, nil}, + "metric_which_discards": {COUNTER, "This metric should be forced to DISCARD", nil, nil}, }, } @@ -84,4 +84,4 @@ func (s *FunctionalSuite) TestSemanticVersionColumnDiscard(c *C) { false, ) } -} \ No newline at end of file +}