From 895166bbbb03127a74af7c90894324e8ca29194a Mon Sep 17 00:00:00 2001 From: Reda NOUSHI Date: Wed, 29 Jun 2016 22:09:42 +0000 Subject: [PATCH] Made cosmetic changes to fit the Go coding standards --- postgres_exporter.go | 62 ++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/postgres_exporter.go b/postgres_exporter.go index fbfd224c..1ce40a33 100644 --- a/postgres_exporter.go +++ b/postgres_exporter.go @@ -222,7 +222,7 @@ var queryOverrides = map[string]string{ } // Add queries to the metricMaps and queryOverrides maps -func add_queries(queriesPath string) (err error) { +func addQueries(queriesPath string) (err error) { var extra map[string]interface{} content, err := ioutil.ReadFile(queriesPath) @@ -258,7 +258,7 @@ func add_queries(queriesPath string) (err error) { for attr_key, attr_val := range a.(map[interface{}]interface{}) { switch(attr_key.(string)) { case "usage": - usage, err := _string_to_columnusage(attr_val.(string)) + usage, err := stringToColumnUsage(attr_val.(string)) if err != nil { return err } @@ -282,34 +282,6 @@ func add_queries(queriesPath string) (err error) { return } -// convert a string to the corresponding ColumnUsage -func _string_to_columnusage(s string) (u ColumnUsage, err error) { - switch(s) { - case "DISCARD": - u = DISCARD - - case "LABEL": - u = LABEL - - case "COUNTER": - u = COUNTER - - case "GAUGE": - u = GAUGE - - case "MAPPEDMETRIC": - u = MAPPEDMETRIC - - case "DURATION": - u = DURATION - default: - err = fmt.Errorf("wrong ColumnUsage given : %s", s) - } - - return -} - - // Turn the MetricMap column mapping into a prometheus descriptor mapping. func makeDescMap(metricMaps map[string]map[string]ColumnMapping) map[string]MetricMapNamespace { var metricMap = make(map[string]MetricMapNamespace) @@ -400,6 +372,34 @@ func makeDescMap(metricMaps map[string]map[string]ColumnMapping) map[string]Metr return metricMap } +// convert a string to the corresponding ColumnUsage +func stringToColumnUsage(s string) (u ColumnUsage, err error) { + switch(s) { + case "DISCARD": + u = DISCARD + + case "LABEL": + u = LABEL + + case "COUNTER": + u = COUNTER + + case "GAUGE": + u = GAUGE + + case "MAPPEDMETRIC": + u = MAPPEDMETRIC + + case "DURATION": + u = DURATION + + default: + err = fmt.Errorf("wrong ColumnUsage given : %s", s) + } + + return +} + // Convert database.sql types to float64s for Prometheus consumption. Null types are mapped to NaN. string and []byte // types are mapped as NaN and !ok func dbToFloat64(t interface{}) (float64, bool) { @@ -672,7 +672,7 @@ func main() { } if *queriesPath != "" { - err := add_queries(*queriesPath) + err := addQueries(*queriesPath) if err != nil { log.Warnln("Unparseable queries file - discarding merge: ", *queriesPath, err) }