Skip to content

Commit b23804b

Browse files
noushiTomas Haber
authored andcommitted
Made cosmetic changes to fit the Go coding standards
1 parent a28532f commit b23804b

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

postgres_exporter.go

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ var queryOverrides = map[string]string{
219219
}
220220

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

225225
content, err := ioutil.ReadFile(queriesPath)
@@ -255,7 +255,7 @@ func add_queries(queriesPath string) (err error) {
255255
for attr_key, attr_val := range a.(map[interface{}]interface{}) {
256256
switch(attr_key.(string)) {
257257
case "usage":
258-
usage, err := _string_to_columnusage(attr_val.(string))
258+
usage, err := stringToColumnUsage(attr_val.(string))
259259
if err != nil {
260260
return err
261261
}
@@ -279,34 +279,6 @@ func add_queries(queriesPath string) (err error) {
279279
return
280280
}
281281

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

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

682682
if *queriesPath != "" {
683-
err := add_queries(*queriesPath)
683+
err := addQueries(*queriesPath)
684684
if err != nil {
685685
log.Warnln("Unparseable queries file - discarding merge: ", *queriesPath, err)
686686
}

0 commit comments

Comments
 (0)