"pg_stat_database_conflicts": map[string]ColumnMapping{ "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}, "confl_lock": {COUNTER, "Number of queries in this database that have been canceled due to lock timeouts", nil, nil}, "confl_snapshot": {COUNTER, "Number of queries in this database that have been canceled due to old snapshots", nil, nil}, "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{ "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{ "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}, "usename": {DISCARD, "Name of the user logged into this WAL sender process", nil, nil}, "application_name": {DISCARD, "Name of the application that is connected to this WAL sender", nil, nil}, "client_addr": {LABEL, "IP address of the client connected to this WAL sender. If this field is null, it indicates that the client is connected via a Unix socket on the server machine.", nil, nil}, "client_hostname": {DISCARD, "Host name of the connected client, as reported by a reverse DNS lookup of client_addr. This field will only be non-null for IP connections, and only when log_hostname is enabled.", nil, nil}, "client_port": {DISCARD, "TCP port number that the client is using for communication with this WAL sender, or -1 if a Unix socket is used", nil, nil}, "backend_start": {DISCARD, "with time zone Time when this process was started, i.e., when the client connected to this WAL sender", nil, nil}, "backend_xmin": {DISCARD, "The current backend's xmin horizon.", nil, nil}, "state": {LABEL, "Current WAL sender state", nil, nil}, "sent_location": {DISCARD, "Last transaction log position sent on this connection", nil, nil}, "write_location": {DISCARD, "Last transaction log position written to disk by this standby server", nil, nil}, "flush_location": {DISCARD, "Last transaction log position flushed to disk by this standby server", nil, nil}, "replay_location": {DISCARD, "Last transaction log position replayed into the database on this standby server", nil, nil}, "sync_priority": {DISCARD, "Priority of this standby server for being chosen as the synchronous standby", nil, nil},
package main import ( "encoding/json" "io" "net/http" "os" "path" "sort" "strconv" "strings" "github.com/blang/semver" ) var allowedRange = semver.MustParseRange(">=1.0.0-beta0") type File struct { Name string `json:"name"` Url string `json:"browser_download_url"` } type Release struct { Version semver.Version Tag string `json:"tag_name"` Files []File `json:"assets"` } type Releases []Release func (rs Releases) Len() int { return len(rs)
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}, }, } { // No metrics should be eliminated resultMap := makeDescMap(semver.MustParse("0.0.1"), testMetricMap) c.Check( resultMap["test_namespace"].columnMappings["metric_which_stays"].discard, Equals, false, ) c.Check( resultMap["test_namespace"].columnMappings["metric_which_discards"].discard, Equals, false, ) } { // Update the map so the discard metric should be eliminated discardable_metric := testMetricMap["test_namespace"]["metric_which_discards"] discardable_metric.supportedVersions = semver.MustParseRange(">0.0.1") testMetricMap["test_namespace"]["metric_which_discards"] = discardable_metric // Discard metric should be discarded resultMap := makeDescMap(semver.MustParse("0.0.1"), testMetricMap) c.Check( resultMap["test_namespace"].columnMappings["metric_which_stays"].discard, Equals, false, ) c.Check( resultMap["test_namespace"].columnMappings["metric_which_discards"].discard, Equals, true, ) } { // Update the map so the discard metric should be kept but has a version discardable_metric := testMetricMap["test_namespace"]["metric_which_discards"] discardable_metric.supportedVersions = semver.MustParseRange(">0.0.1") testMetricMap["test_namespace"]["metric_which_discards"] = discardable_metric // Discard metric should be discarded resultMap := makeDescMap(semver.MustParse("0.0.2"), testMetricMap) c.Check( resultMap["test_namespace"].columnMappings["metric_which_stays"].discard, Equals, false, ) c.Check( resultMap["test_namespace"].columnMappings["metric_which_discards"].discard, Equals, false, ) } }