refactoring: minor refactoring and handling of known data source plugins

This commit is contained in:
Torkel Ödegaard
2015-10-26 16:37:45 +01:00
parent 3b67a6a222
commit 323e84375b
2 changed files with 20 additions and 18 deletions

View File

@ -67,7 +67,7 @@ func sendUsageStats() {
// as sending that name could be sensitive information
dsOtherCount := 0
for _, dsStat := range dsStats.Result {
if m.IsStandardDataSource(dsStat.Type) {
if m.IsKnownDataSourcePlugin(dsStat.Type) {
metrics["stats.ds."+dsStat.Type+".count"] = dsStat.Count
} else {
dsOtherCount += dsStat.Count

View File

@ -47,23 +47,25 @@ type DataSource struct {
Updated time.Time
}
func IsStandardDataSource(dsType string) bool {
switch dsType {
case DS_ES:
return true
case DS_INFLUXDB:
return true
case DS_OPENTSDB:
return true
case DS_CLOUDWATCH:
return true
case DS_PROMETHEUS:
return true
case DS_GRAPHITE:
return true
default:
return false
}
var knownDatasourcePlugins map[string]bool = map[string]bool{
DS_ES: true,
DS_GRAPHITE: true,
DS_INFLUXDB: true,
DS_INFLUXDB_08: true,
DS_KAIROSDB: true,
DS_CLOUDWATCH: true,
DS_PROMETHEUS: true,
DS_OPENTSDB: true,
"opennms": true,
"druid": true,
"dalmatinerdb": true,
"gnocci": true,
"zabbix": true,
}
func IsKnownDataSourcePlugin(dsType string) bool {
_, exists := knownDatasourcePlugins[dsType]
return exists
}
// ----------------------