1
0
mirror of https://github.com/prometheus-community/postgres_exporter.git synced 2025-08-05 06:21:12 +03:00

Use correct SemVer range condition. Fixes #38 (#39)

This commit is contained in:
Dominik Schulz
2016-11-28 15:49:25 +01:00
committed by Will Rouesnel
parent 37e6dd3bec
commit 8f3088611b

View File

@@ -2,25 +2,24 @@ package main
import ( import (
"database/sql" "database/sql"
"errors"
"flag" "flag"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"math" "math"
"net/http" "net/http"
"os" "os"
"strconv"
"time"
"regexp" "regexp"
"errors" "strconv"
"sync" "sync"
"time"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
"github.com/blang/semver"
_ "github.com/lib/pq" _ "github.com/lib/pq"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/log" "github.com/prometheus/common/log"
"github.com/blang/semver"
) )
var Version string = "0.0.1" var Version string = "0.0.1"
@@ -358,7 +357,6 @@ var queryOverrides = map[string][]OverrideQuery{
}, },
// No query is applicable for 9.1 that gives any sensible data. // No query is applicable for 9.1 that gives any sensible data.
}, },
} }
// Convert the query override file to the version-specific query override file // Convert the query override file to the version-specific query override file
@@ -509,7 +507,7 @@ func makeDescMap(pgVersion semver.Version, metricMaps map[string]map[string]Colu
// Check column version compatibility for the current map // Check column version compatibility for the current map
// Force to discard if not compatible. // Force to discard if not compatible.
if columnMapping.supportedVersions != nil { if columnMapping.supportedVersions != nil {
if columnMapping.supportedVersions(pgVersion) { if !columnMapping.supportedVersions(pgVersion) {
thisMap[columnName] = MetricMap{ thisMap[columnName] = MetricMap{
discard: true, discard: true,
conversion: func(in interface{}) (float64, bool) { conversion: func(in interface{}) (float64, bool) {
@@ -948,7 +946,7 @@ func (e *Exporter) checkMapVersions(ch chan<- prometheus.Metric, db *sql.DB) err
e.lastMapVersion = semanticVersion e.lastMapVersion = semanticVersion
if e.userQueriesPath != "" { if e.userQueriesPath != "" {
if err := addQueries(e.userQueriesPath, semanticVersion, e.metricMap, e.queryOverrides) ; err != nil { if err := addQueries(e.userQueriesPath, semanticVersion, e.metricMap, e.queryOverrides); err != nil {
log.Errorln("Failed to reload user queries:", e.userQueriesPath, err) log.Errorln("Failed to reload user queries:", e.userQueriesPath, err)
} }
} }