Skip to content

Commit 895166b

Browse files
committed
Made cosmetic changes to fit the Go coding standards
1 parent 8dd3912 commit 895166b

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

postgres_exporter.go

+31-31
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ var queryOverrides = map[string]string{
222222
}
223223

224224
// Add queries to the metricMaps and queryOverrides maps
225-
func add_queries(queriesPath string) (err error) {
225+
func addQueries(queriesPath string) (err error) {
226226
var extra map[string]interface{}
227227

228228
content, err := ioutil.ReadFile(queriesPath)
@@ -258,7 +258,7 @@ func add_queries(queriesPath string) (err error) {
258258
for attr_key, attr_val := range a.(map[interface{}]interface{}) {
259259
switch(attr_key.(string)) {
260260
case "usage":
261-
usage, err := _string_to_columnusage(attr_val.(string))
261+
usage, err := stringToColumnUsage(attr_val.(string))
262262
if err != nil {
263263
return err
264264
}
@@ -282,34 +282,6 @@ func add_queries(queriesPath string) (err error) {
282282
return
283283
}
284284

285-
// convert a string to the corresponding ColumnUsage
286-
func _string_to_columnusage(s string) (u ColumnUsage, err error) {
287-
switch(s) {
288-
case "DISCARD":
289-
u = DISCARD
290-
291-
case "LABEL":
292-
u = LABEL
293-
294-
case "COUNTER":
295-
u = COUNTER
296-
297-
case "GAUGE":
298-
u = GAUGE
299-
300-
case "MAPPEDMETRIC":
301-
u = MAPPEDMETRIC
302-
303-
case "DURATION":
304-
u = DURATION
305-
default:
306-
err = fmt.Errorf("wrong ColumnUsage given : %s", s)
307-
}
308-
309-
return
310-
}
311-
312-
313285
// Turn the MetricMap column mapping into a prometheus descriptor mapping.
314286
func makeDescMap(metricMaps map[string]map[string]ColumnMapping) map[string]MetricMapNamespace {
315287
var metricMap = make(map[string]MetricMapNamespace)
@@ -400,6 +372,34 @@ func makeDescMap(metricMaps map[string]map[string]ColumnMapping) map[string]Metr
400372
return metricMap
401373
}
402374

375+
// convert a string to the corresponding ColumnUsage
376+
func stringToColumnUsage(s string) (u ColumnUsage, err error) {
377+
switch(s) {
378+
case "DISCARD":
379+
u = DISCARD
380+
381+
case "LABEL":
382+
u = LABEL
383+
384+
case "COUNTER":
385+
u = COUNTER
386+
387+
case "GAUGE":
388+
u = GAUGE
389+
390+
case "MAPPEDMETRIC":
391+
u = MAPPEDMETRIC
392+
393+
case "DURATION":
394+
u = DURATION
395+
396+
default:
397+
err = fmt.Errorf("wrong ColumnUsage given : %s", s)
398+
}
399+
400+
return
401+
}
402+
403403
// Convert database.sql types to float64s for Prometheus consumption. Null types are mapped to NaN. string and []byte
404404
// types are mapped as NaN and !ok
405405
func dbToFloat64(t interface{}) (float64, bool) {
@@ -672,7 +672,7 @@ func main() {
672672
}
673673

674674
if *queriesPath != "" {
675-
err := add_queries(*queriesPath)
675+
err := addQueries(*queriesPath)
676676
if err != nil {
677677
log.Warnln("Unparseable queries file - discarding merge: ", *queriesPath, err)
678678
}

0 commit comments

Comments
 (0)