From 323e84375bae6c0032422e155814c40b6a42aee6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 26 Oct 2015 16:37:45 +0100 Subject: [PATCH] refactoring: minor refactoring and handling of known data source plugins --- pkg/metrics/report_usage.go | 2 +- pkg/models/datasource.go | 36 +++++++++++++++++++----------------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/pkg/metrics/report_usage.go b/pkg/metrics/report_usage.go index 065c83d3b8f..abda18d12b7 100644 --- a/pkg/metrics/report_usage.go +++ b/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 diff --git a/pkg/models/datasource.go b/pkg/models/datasource.go index 35b623ce30a..38273598ab1 100644 --- a/pkg/models/datasource.go +++ b/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 } // ----------------------