Просмотр исходного кода

refactoring: minor refactoring and handling of known data source plugins

Torkel Ödegaard 10 лет назад
Родитель
Сommit
323e84375b
2 измененных файлов с 20 добавлено и 18 удалено
  1. 1 1
      pkg/metrics/report_usage.go
  2. 19 17
      pkg/models/datasource.go

+ 1 - 1
pkg/metrics/report_usage.go

@@ -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

+ 19 - 17
pkg/models/datasource.go

@@ -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
 }
 
 // ----------------------