From 38c61c07efa77ea6f385cca9566cb3f3af629cd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20=C5=BBak?= Date: Fri, 12 Mar 2021 21:21:51 +0100 Subject: [PATCH] Revive fixes - part 4: (#8981) empty-lines Co-authored-by: Pawel Zak --- agent/agent.go | 1 - config/config.go | 1 - internal/content_coding.go | 1 - internal/globpath/globpath_test.go | 1 - internal/http.go | 2 -- metric/tracking.go | 1 - models/filter_test.go | 3 --- models/running_output.go | 1 - plugins/aggregators/basicstats/basicstats.go | 1 - .../aggregators/basicstats/basicstats_test.go | 17 ----------------- .../aggregators/derivative/derivative_test.go | 1 - plugins/aggregators/histogram/histogram_test.go | 1 - plugins/common/kafka/sasl.go | 1 - plugins/common/shim/config.go | 2 -- plugins/inputs/activemq/activemq_test.go | 3 --- plugins/inputs/aerospike/aerospike.go | 7 ------- plugins/inputs/aerospike/aerospike_test.go | 8 -------- plugins/inputs/aliyuncms/aliyuncms.go | 16 ++-------------- plugins/inputs/aliyuncms/aliyuncms_test.go | 7 ------- plugins/inputs/aliyuncms/discovery.go | 10 ---------- plugins/inputs/apache/apache.go | 1 - plugins/inputs/apcupsd/apcupsd_test.go | 2 -- plugins/inputs/beat/beat_test.go | 1 - plugins/inputs/cassandra/cassandra.go | 6 +----- plugins/inputs/cassandra/cassandra_test.go | 4 +--- plugins/inputs/ceph/ceph.go | 3 --- plugins/inputs/ceph/ceph_test.go | 1 - plugins/inputs/chrony/chrony_test.go | 2 -- .../cisco_telemetry_mdt_test.go | 1 - plugins/inputs/clickhouse/clickhouse.go | 9 --------- plugins/inputs/clickhouse/clickhouse_test.go | 1 - plugins/inputs/couchbase/couchbase_test.go | 1 - plugins/inputs/csgo/csgo.go | 4 ++-- plugins/inputs/dcos/client.go | 1 - plugins/inputs/dcos/client_test.go | 3 --- plugins/inputs/dcos/dcos_test.go | 1 - plugins/inputs/diskio/diskio.go | 1 - plugins/inputs/diskio/diskio_linux_test.go | 1 - plugins/inputs/disque/disque.go | 1 - plugins/inputs/docker/docker_test.go | 3 --- plugins/inputs/dovecot/dovecot.go | 3 --- plugins/inputs/dovecot/dovecot_test.go | 2 -- plugins/inputs/ecs/client.go | 1 - plugins/inputs/ecs/client_test.go | 1 - plugins/inputs/ecs/stats.go | 1 - plugins/inputs/elasticsearch/elasticsearch.go | 2 -- plugins/inputs/exec/exec.go | 1 - plugins/inputs/execd/execd_test.go | 1 - plugins/inputs/fibaro/fibaro.go | 1 - plugins/inputs/filecount/filecount.go | 1 - plugins/inputs/filecount/filecount_test.go | 4 +--- plugins/inputs/filecount/filesystem_helpers.go | 1 - .../inputs/filecount/filesystem_helpers_test.go | 4 +--- plugins/inputs/fireboard/fireboard.go | 2 -- plugins/inputs/fluentd/fluentd.go | 4 ---- plugins/inputs/fluentd/fluentd_test.go | 3 --- plugins/inputs/gnmi/gnmi.go | 1 - plugins/inputs/haproxy/haproxy.go | 1 - plugins/inputs/hddtemp/hddtemp_test.go | 2 -- .../inputs/http_listener_v2/http_listener_v2.go | 1 - plugins/inputs/infiniband/infiniband_test.go | 1 - .../influxdb_listener/influxdb_listener.go | 1 - plugins/inputs/intel_powerstat/rapl.go | 5 ++--- plugins/inputs/intel_rdt/intel_rdt.go | 6 ++---- plugins/inputs/ipmi_sensor/ipmi_test.go | 2 -- plugins/inputs/jenkins/jenkins.go | 2 -- plugins/inputs/jenkins/jenkins_test.go | 1 - plugins/inputs/jolokia/jolokia.go | 1 - plugins/inputs/jolokia/jolokia_test.go | 8 ++------ plugins/inputs/jolokia2/gatherer.go | 1 - plugins/inputs/jolokia2/jolokia_agent.go | 3 +-- plugins/inputs/jolokia2/point_builder.go | 4 ---- .../openconfig_telemetry.go | 1 - plugins/inputs/kapacitor/kapacitor.go | 1 - plugins/inputs/kernel/kernel.go | 1 - plugins/inputs/kernel_vmstat/kernel_vmstat.go | 1 - plugins/inputs/kibana/kibana.go | 3 --- plugins/inputs/kubernetes/kubernetes.go | 1 - plugins/inputs/kubernetes/kubernetes_test.go | 2 -- plugins/inputs/lanz/lanz.go | 1 - plugins/inputs/lanz/lanz_test.go | 2 -- .../inputs/linux_sysctl_fs/linux_sysctl_fs.go | 1 - plugins/inputs/logparser/logparser.go | 2 -- plugins/inputs/logstash/logstash.go | 11 +++++------ plugins/inputs/logstash/logstash_test.go | 3 --- plugins/inputs/lustre2/lustre2_test.go | 2 -- plugins/inputs/mailchimp/mailchimp_test.go | 1 - plugins/inputs/marklogic/marklogic.go | 1 - plugins/inputs/marklogic/marklogic_test.go | 1 - plugins/inputs/mesos/mesos_test.go | 1 - plugins/inputs/minecraft/client.go | 1 - plugins/inputs/modbus/modbus.go | 1 - plugins/inputs/mongodb/mongostat.go | 3 +-- plugins/inputs/mongodb/mongostat_test.go | 3 --- plugins/inputs/monit/monit.go | 7 +------ plugins/inputs/monit/monit_test.go | 6 ------ plugins/inputs/mysql/mysql.go | 3 +-- .../inputs/neptune_apex/neptune_apex_test.go | 1 - plugins/inputs/nfsclient/nfsclient.go | 4 ---- plugins/inputs/nfsclient/nfsclient_test.go | 1 - plugins/inputs/nginx_plus/nginx_plus.go | 1 - plugins/inputs/nginx_plus/nginx_plus_test.go | 1 - .../nginx_plus_api_metrics_test.go | 1 - .../nginx_upstream_check.go | 3 --- .../nginx_upstream_check_test.go | 1 - plugins/inputs/nsd/nsd_test.go | 1 - .../inputs/nsq_consumer/nsq_consumer_test.go | 1 - plugins/inputs/opcua/opcua_util.go | 2 -- plugins/inputs/openntpd/openntpd.go | 7 ------- plugins/inputs/opensmtpd/opensmtpd.go | 1 - plugins/inputs/openweathermap/openweathermap.go | 1 - plugins/inputs/pf/pf.go | 1 - plugins/inputs/phpfpm/phpfpm_test.go | 1 - plugins/inputs/ping/ping.go | 1 - plugins/inputs/ping/ping_test.go | 1 - plugins/inputs/powerdns/powerdns_test.go | 1 - plugins/inputs/procstat/native_finder.go | 1 - plugins/inputs/procstat/procstat.go | 1 - plugins/inputs/prometheus/kubernetes.go | 4 ---- plugins/inputs/prometheus/kubernetes_test.go | 1 - plugins/inputs/prometheus/parser.go | 1 - plugins/inputs/prometheus/parser_test.go | 1 - plugins/inputs/prometheus/prometheus.go | 1 - plugins/inputs/prometheus/prometheus_test.go | 1 - plugins/inputs/puppetagent/puppetagent.go | 1 - plugins/inputs/raindrops/raindrops.go | 1 - plugins/inputs/redfish/redfish_test.go | 12 ------------ .../inputs/riemann_listener/riemann_listener.go | 4 ---- .../riemann_listener/riemann_listener_test.go | 2 -- plugins/inputs/sensors/sensors.go | 1 - plugins/inputs/sensors/sensors_test.go | 1 - plugins/inputs/sflow/sflow.go | 1 - plugins/inputs/snmp/snmp.go | 1 - plugins/inputs/snmp_trap/snmp_trap.go | 1 - plugins/inputs/snmp_trap/snmp_trap_test.go | 1 - plugins/inputs/solr/solr.go | 1 - plugins/inputs/solr/solr_test.go | 1 - plugins/inputs/sqlserver/sqlserver_test.go | 6 ------ plugins/inputs/stackdriver/stackdriver_test.go | 1 - plugins/inputs/suricata/suricata_test.go | 2 -- plugins/inputs/sysstat/sysstat.go | 2 -- plugins/inputs/temp/temp_test.go | 1 - plugins/inputs/trig/trig_test.go | 1 - plugins/inputs/unbound/unbound.go | 3 --- plugins/inputs/uwsgi/uwsgi.go | 1 - plugins/inputs/vsphere/endpoint.go | 2 -- plugins/inputs/vsphere/vsphere.go | 1 - plugins/inputs/vsphere/vsphere_test.go | 1 - .../webhooks/papertrail/papertrail_webhooks.go | 3 --- plugins/inputs/webhooks/webhooks.go | 1 - plugins/inputs/x509_cert/x509_cert_test.go | 1 - .../application_insights.go | 8 ++++---- .../application_insights_test.go | 2 -- plugins/outputs/cloud_pubsub/pubsub_test.go | 2 -- plugins/outputs/cloudwatch/cloudwatch.go | 9 --------- plugins/outputs/cratedb/cratedb.go | 1 - plugins/outputs/elasticsearch/elasticsearch.go | 9 --------- .../outputs/elasticsearch/elasticsearch_test.go | 3 --- plugins/outputs/graphite/graphite.go | 3 +-- plugins/outputs/graylog/graylog.go | 1 - plugins/outputs/health/health.go | 1 - plugins/outputs/influxdb/udp.go | 1 - plugins/outputs/kafka/kafka.go | 1 - plugins/outputs/kinesis/kinesis.go | 2 -- plugins/outputs/kinesis/kinesis_test.go | 12 ------------ plugins/outputs/librato/librato.go | 2 -- plugins/outputs/librato/librato_test.go | 1 - .../outputs/prometheus_client/v1/collector.go | 2 -- .../timestream/timestream_internal_test.go | 1 - plugins/outputs/warp10/warp10.go | 3 --- plugins/outputs/warp10/warp10_test.go | 1 - plugins/outputs/wavefront/wavefront.go | 3 --- plugins/outputs/wavefront/wavefront_test.go | 6 ------ plugins/parsers/dropwizard/parser.go | 4 ---- plugins/parsers/grok/parser.go | 1 - plugins/parsers/grok/parser_test.go | 1 - plugins/parsers/json/parser.go | 2 -- plugins/parsers/json/parser_test.go | 1 - plugins/parsers/wavefront/element.go | 1 - plugins/parsers/wavefront/parser.go | 3 --- plugins/parsers/wavefront/parser_test.go | 5 ----- plugins/parsers/wavefront/scanner.go | 1 - plugins/processors/date/date_test.go | 1 - plugins/processors/filepath/filepath.go | 1 - plugins/processors/port_name/port_name.go | 1 - plugins/processors/starlark/builtins.go | 1 - plugins/processors/topk/topk.go | 1 - plugins/processors/topk/topk_test.go | 14 -------------- plugins/serializers/msgpack/msgpack.go | 1 - plugins/serializers/prometheus/collection.go | 2 -- .../prometheusremotewrite.go | 3 --- .../serializers/splunkmetric/splunkmetric.go | 4 ---- testutil/accumulator.go | 1 - testutil/testutil_test.go | 2 -- 194 files changed, 28 insertions(+), 457 deletions(-) diff --git a/agent/agent.go b/agent/agent.go index 1ac5f2b0b..fb2c75b90 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -364,7 +364,6 @@ func (a *Agent) testStartInputs( if err != nil { log.Printf("E! [agent] Starting input %s: %v", input.LogName(), err) } - } unit.inputs = append(unit.inputs, input) diff --git a/config/config.go b/config/config.go index be64fba4b..55d101cbf 100644 --- a/config/config.go +++ b/config/config.go @@ -908,7 +908,6 @@ func loadConfig(config string) ([]byte, error) { // If it isn't a https scheme, try it as a file. } return ioutil.ReadFile(config) - } func fetchConfig(u *url.URL) ([]byte, error) { diff --git a/internal/content_coding.go b/internal/content_coding.go index daefa20ee..b1a30bde1 100644 --- a/internal/content_coding.go +++ b/internal/content_coding.go @@ -65,7 +65,6 @@ func (r *GzipReader) Read(b []byte) (int, error) { return n, nil } return n, err - } // NewContentEncoder returns a ContentEncoder for the encoding type. diff --git a/internal/globpath/globpath_test.go b/internal/globpath/globpath_test.go index 4897ab2f8..33779f912 100644 --- a/internal/globpath/globpath_test.go +++ b/internal/globpath/globpath_test.go @@ -19,7 +19,6 @@ var ( ) func TestCompileAndMatch(t *testing.T) { - type test struct { path string matches int diff --git a/internal/http.go b/internal/http.go index 1c3dd4957..12adfe729 100644 --- a/internal/http.go +++ b/internal/http.go @@ -37,7 +37,6 @@ func (h *basicAuthHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request) if !ok || subtle.ConstantTimeCompare([]byte(reqUsername), []byte(h.username)) != 1 || subtle.ConstantTimeCompare([]byte(reqPassword), []byte(h.password)) != 1 { - rw.Header().Set("WWW-Authenticate", "Basic realm=\""+h.realm+"\"") h.onError(rw) http.Error(rw, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized) @@ -73,7 +72,6 @@ func (h *genericAuthHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request // Scheme checking authorization := req.Header.Get("Authorization") if subtle.ConstantTimeCompare([]byte(authorization), []byte(h.credentials)) != 1 { - h.onError(rw) http.Error(rw, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized) return diff --git a/metric/tracking.go b/metric/tracking.go index e370d9f2a..e0bf5ff8e 100644 --- a/metric/tracking.go +++ b/metric/tracking.go @@ -117,7 +117,6 @@ func newTrackingMetricGroup(group []telegraf.Metric, fn NotifyFunc) ([]telegraf. d: d, } group[i] = dm - } if finalizer != nil { runtime.SetFinalizer(d, finalizer) diff --git a/models/filter_test.go b/models/filter_test.go index d241244b9..7e82ba000 100644 --- a/models/filter_test.go +++ b/models/filter_test.go @@ -402,7 +402,6 @@ func TestFilter_FilterTagsMatches(t *testing.T) { // both parameters were defined // see: https://github.com/influxdata/telegraf/issues/2860 func TestFilter_FilterNamePassAndDrop(t *testing.T) { - inputData := []string{"name1", "name2", "name3", "name4"} expectedResult := []bool{false, true, false, false} @@ -422,7 +421,6 @@ func TestFilter_FilterNamePassAndDrop(t *testing.T) { // both parameters were defined // see: https://github.com/influxdata/telegraf/issues/2860 func TestFilter_FilterFieldPassAndDrop(t *testing.T) { - inputData := []string{"field1", "field2", "field3", "field4"} expectedResult := []bool{false, true, false, false} @@ -479,7 +477,6 @@ func TestFilter_FilterTagsPassAndDrop(t *testing.T) { for i, tag := range inputData { require.Equal(t, f.shouldTagsPass(tag), expectedResult[i]) } - } func BenchmarkFilter(b *testing.B) { diff --git a/models/running_output.go b/models/running_output.go index fd048df6f..b7f3fe03f 100644 --- a/models/running_output.go +++ b/models/running_output.go @@ -125,7 +125,6 @@ func (r *RunningOutput) Init() error { if err != nil { return err } - } return nil } diff --git a/plugins/aggregators/basicstats/basicstats.go b/plugins/aggregators/basicstats/basicstats.go index b335ec4f0..4ad6c7705 100644 --- a/plugins/aggregators/basicstats/basicstats.go +++ b/plugins/aggregators/basicstats/basicstats.go @@ -167,7 +167,6 @@ func (b *BasicStats) Push(acc telegraf.Accumulator) { for _, aggregate := range b.cache { fields := map[string]interface{}{} for k, v := range aggregate.fields { - if b.statsConfig.count { fields[k+"_count"] = v.count } diff --git a/plugins/aggregators/basicstats/basicstats_test.go b/plugins/aggregators/basicstats/basicstats_test.go index 8b2e9c739..8e8ee6da7 100644 --- a/plugins/aggregators/basicstats/basicstats_test.go +++ b/plugins/aggregators/basicstats/basicstats_test.go @@ -184,7 +184,6 @@ func TestBasicStatsDifferentPeriods(t *testing.T) { // Test only aggregating count func TestBasicStatsWithOnlyCount(t *testing.T) { - aggregator := NewBasicStats() aggregator.Stats = []string{"count"} aggregator.Log = testutil.Logger{} @@ -213,7 +212,6 @@ func TestBasicStatsWithOnlyCount(t *testing.T) { // Test only aggregating minimum func TestBasicStatsWithOnlyMin(t *testing.T) { - aggregator := NewBasicStats() aggregator.Stats = []string{"min"} aggregator.Log = testutil.Logger{} @@ -242,7 +240,6 @@ func TestBasicStatsWithOnlyMin(t *testing.T) { // Test only aggregating maximum func TestBasicStatsWithOnlyMax(t *testing.T) { - aggregator := NewBasicStats() aggregator.Stats = []string{"max"} aggregator.Log = testutil.Logger{} @@ -271,7 +268,6 @@ func TestBasicStatsWithOnlyMax(t *testing.T) { // Test only aggregating mean func TestBasicStatsWithOnlyMean(t *testing.T) { - aggregator := NewBasicStats() aggregator.Stats = []string{"mean"} aggregator.Log = testutil.Logger{} @@ -300,7 +296,6 @@ func TestBasicStatsWithOnlyMean(t *testing.T) { // Test only aggregating sum func TestBasicStatsWithOnlySum(t *testing.T) { - aggregator := NewBasicStats() aggregator.Stats = []string{"sum"} aggregator.Log = testutil.Logger{} @@ -331,7 +326,6 @@ func TestBasicStatsWithOnlySum(t *testing.T) { // implementations of sum were calculated from mean and count, which // e.g. summed "1, 1, 5, 1" as "7.999999..." instead of 8. func TestBasicStatsWithOnlySumFloatingPointErrata(t *testing.T) { - var sum1, _ = metric.New("m1", map[string]string{}, map[string]interface{}{ @@ -383,7 +377,6 @@ func TestBasicStatsWithOnlySumFloatingPointErrata(t *testing.T) { // Test only aggregating variance func TestBasicStatsWithOnlyVariance(t *testing.T) { - aggregator := NewBasicStats() aggregator.Stats = []string{"s2"} aggregator.Log = testutil.Logger{} @@ -410,7 +403,6 @@ func TestBasicStatsWithOnlyVariance(t *testing.T) { // Test only aggregating standard deviation func TestBasicStatsWithOnlyStandardDeviation(t *testing.T) { - aggregator := NewBasicStats() aggregator.Stats = []string{"stdev"} aggregator.Log = testutil.Logger{} @@ -437,7 +429,6 @@ func TestBasicStatsWithOnlyStandardDeviation(t *testing.T) { // Test only aggregating minimum and maximum func TestBasicStatsWithMinAndMax(t *testing.T) { - aggregator := NewBasicStats() aggregator.Stats = []string{"min", "max"} aggregator.Log = testutil.Logger{} @@ -473,7 +464,6 @@ func TestBasicStatsWithMinAndMax(t *testing.T) { // Test only aggregating diff func TestBasicStatsWithDiff(t *testing.T) { - aggregator := NewBasicStats() aggregator.Stats = []string{"diff"} aggregator.Log = testutil.Logger{} @@ -499,7 +489,6 @@ func TestBasicStatsWithDiff(t *testing.T) { } func TestBasicStatsWithRate(t *testing.T) { - aggregator := NewBasicStats() aggregator.Stats = []string{"rate"} aggregator.Log = testutil.Logger{} @@ -524,7 +513,6 @@ func TestBasicStatsWithRate(t *testing.T) { } func TestBasicStatsWithNonNegativeRate(t *testing.T) { - aggregator := NewBasicStats() aggregator.Stats = []string{"non_negative_rate"} aggregator.Log = testutil.Logger{} @@ -548,7 +536,6 @@ func TestBasicStatsWithNonNegativeRate(t *testing.T) { acc.AssertContainsTaggedFields(t, "m1", expectedFields, expectedTags) } func TestBasicStatsWithInterval(t *testing.T) { - aggregator := NewBasicStats() aggregator.Stats = []string{"interval"} aggregator.Log = testutil.Logger{} @@ -575,7 +562,6 @@ func TestBasicStatsWithInterval(t *testing.T) { // Test only aggregating non_negative_diff func TestBasicStatsWithNonNegativeDiff(t *testing.T) { - aggregator := NewBasicStats() aggregator.Stats = []string{"non_negative_diff"} aggregator.Log = testutil.Logger{} @@ -666,7 +652,6 @@ func TestBasicStatsWithAllStats(t *testing.T) { // Test that if an empty array is passed, no points are pushed func TestBasicStatsWithNoStats(t *testing.T) { - aggregator := NewBasicStats() aggregator.Stats = []string{} aggregator.Log = testutil.Logger{} @@ -683,7 +668,6 @@ func TestBasicStatsWithNoStats(t *testing.T) { // Test that if an unknown stat is configured, it doesn't explode func TestBasicStatsWithUnknownStat(t *testing.T) { - aggregator := NewBasicStats() aggregator.Stats = []string{"crazy"} aggregator.Log = testutil.Logger{} @@ -703,7 +687,6 @@ func TestBasicStatsWithUnknownStat(t *testing.T) { // otherwise user's working systems will suddenly (and surprisingly) start // capturing sum without their input. func TestBasicStatsWithDefaultStats(t *testing.T) { - aggregator := NewBasicStats() aggregator.Log = testutil.Logger{} aggregator.getConfiguredStats() diff --git a/plugins/aggregators/derivative/derivative_test.go b/plugins/aggregators/derivative/derivative_test.go index 1549500f7..9a2f34ac7 100644 --- a/plugins/aggregators/derivative/derivative_test.go +++ b/plugins/aggregators/derivative/derivative_test.go @@ -119,7 +119,6 @@ func TestTwoFullEventsWithoutParameter(t *testing.T) { "value_rate": float64(5), }, ) - } func TestTwoFullEventsInSeperatePushes(t *testing.T) { diff --git a/plugins/aggregators/histogram/histogram_test.go b/plugins/aggregators/histogram/histogram_test.go index dfb3f5d12..aa6214b3b 100644 --- a/plugins/aggregators/histogram/histogram_test.go +++ b/plugins/aggregators/histogram/histogram_test.go @@ -210,7 +210,6 @@ func TestHistogramWithAllFieldsNonCumulative(t *testing.T) { // TestHistogramWithTwoPeriodsAndAllFields tests two metrics getting added with a push/reset in between (simulates // getting added in different periods) for all fields func TestHistogramWithTwoPeriodsAndAllFields(t *testing.T) { - var cfg []config cfg = append(cfg, config{Metric: "first_metric_name", Buckets: []float64{0.0, 10.0, 20.0, 30.0, 40.0}}) histogram := NewTestHistogram(cfg, false, true) diff --git a/plugins/common/kafka/sasl.go b/plugins/common/kafka/sasl.go index e565aea58..06ab64dab 100644 --- a/plugins/common/kafka/sasl.go +++ b/plugins/common/kafka/sasl.go @@ -105,5 +105,4 @@ func gssapiAuthType(authType string) int { default: return 0 } - } diff --git a/plugins/common/shim/config.go b/plugins/common/shim/config.go index 078887527..a0bb3ce0d 100644 --- a/plugins/common/shim/config.go +++ b/plugins/common/shim/config.go @@ -53,14 +53,12 @@ func LoadConfig(filePath *string) (loaded loadedConfig, err error) { var data string conf := config{} if filePath != nil && *filePath != "" { - b, err := ioutil.ReadFile(*filePath) if err != nil { return loadedConfig{}, err } data = expandEnvVars(b) - } else { conf, err = DefaultImportedPlugins() if err != nil { diff --git a/plugins/inputs/activemq/activemq_test.go b/plugins/inputs/activemq/activemq_test.go index 407a38177..0cec2e330 100644 --- a/plugins/inputs/activemq/activemq_test.go +++ b/plugins/inputs/activemq/activemq_test.go @@ -11,7 +11,6 @@ import ( ) func TestGatherQueuesMetrics(t *testing.T) { - s := ` @@ -57,7 +56,6 @@ func TestGatherQueuesMetrics(t *testing.T) { } func TestGatherTopicsMetrics(t *testing.T) { - s := ` @@ -104,7 +102,6 @@ func TestGatherTopicsMetrics(t *testing.T) { } func TestGatherSubscribersMetrics(t *testing.T) { - s := ` diff --git a/plugins/inputs/aerospike/aerospike.go b/plugins/inputs/aerospike/aerospike.go index e470b58a4..b5c13ddc4 100644 --- a/plugins/inputs/aerospike/aerospike.go +++ b/plugins/inputs/aerospike/aerospike.go @@ -248,7 +248,6 @@ func (a *Aerospike) parseNodeInfo(stats map[string]string, hostPort string, node for k, v := range stats { key := strings.Replace(k, "-", "_", -1) fields[key] = parseAerospikeValue(key, v) - } acc.AddFields("aerospike_node", fields, tags, time.Now()) @@ -279,7 +278,6 @@ func (a *Aerospike) getNamespaceInfo(namespace string, n *as.Node) (map[string]s return stats, err } func (a *Aerospike) parseNamespaceInfo(stats map[string]string, hostPort string, namespace string, nodeName string, acc telegraf.Accumulator) { - nTags := map[string]string{ "aerospike_host": hostPort, "node_name": nodeName, @@ -348,7 +346,6 @@ func (a *Aerospike) getSetInfo(namespaceSet string, n *as.Node) (map[string]stri } func (a *Aerospike) parseSetInfo(stats map[string]string, hostPort string, namespaceSet string, nodeName string, acc telegraf.Accumulator) { - stat := strings.Split( strings.TrimSuffix( stats[fmt.Sprintf("sets/%s", namespaceSet)], ";"), ":") @@ -383,7 +380,6 @@ func (a *Aerospike) getTTLHistogram(hostPort string, namespace string, set strin } func (a *Aerospike) getObjectSizeLinearHistogram(hostPort string, namespace string, set string, n *as.Node, acc telegraf.Accumulator) error { - stats, err := a.getHistogram(namespace, set, "object-size-linear", n) if err != nil { return err @@ -406,11 +402,9 @@ func (a *Aerospike) getHistogram(namespace string, set string, histogramType str return nil, err } return stats, nil - } func (a *Aerospike) parseHistogram(stats map[string]string, hostPort string, namespace string, set string, histogramType string, nodeName string, acc telegraf.Accumulator) { - nTags := map[string]string{ "aerospike_host": hostPort, "node_name": nodeName, @@ -463,7 +457,6 @@ func (a *Aerospike) parseHistogram(stats map[string]string, hostPort string, nam nFields[strconv.Itoa(bucketName)] = bucketSum } } - } } } diff --git a/plugins/inputs/aerospike/aerospike_test.go b/plugins/inputs/aerospike/aerospike_test.go index efc10b5d9..57d37a06c 100644 --- a/plugins/inputs/aerospike/aerospike_test.go +++ b/plugins/inputs/aerospike/aerospike_test.go @@ -31,7 +31,6 @@ func TestAerospikeStatisticsIntegration(t *testing.T) { namespaceName := acc.TagValue("aerospike_namespace", "namespace") assert.Equal(t, namespaceName, "test") - } func TestAerospikeStatisticsPartialErrIntegration(t *testing.T) { @@ -165,7 +164,6 @@ func TestQuerySetsIntegration(t *testing.T) { assert.True(t, acc.HasMeasurement("aerospike_set")) assert.True(t, acc.HasTag("aerospike_set", "set")) assert.True(t, acc.HasInt64Field("aerospike_set", "memory_data_bytes")) - } func TestSelectQuerySetsIntegration(t *testing.T) { @@ -215,7 +213,6 @@ func TestSelectQuerySetsIntegration(t *testing.T) { assert.True(t, acc.HasMeasurement("aerospike_set")) assert.True(t, acc.HasTag("aerospike_set", "set")) assert.True(t, acc.HasInt64Field("aerospike_set", "memory_data_bytes")) - } func TestDisableTTLHistogramIntegration(t *testing.T) { @@ -264,7 +261,6 @@ func TestTTLHistogramIntegration(t *testing.T) { assert.True(t, acc.HasMeasurement("aerospike_histogram_ttl")) assert.True(t, FindTagValue(&acc, "aerospike_histogram_ttl", "namespace", "test")) - } func TestDisableObjectSizeLinearHistogramIntegration(t *testing.T) { if testing.Short() { @@ -287,7 +283,6 @@ func TestDisableObjectSizeLinearHistogramIntegration(t *testing.T) { assert.False(t, acc.HasMeasurement("aerospike_histogram_object_size_linear")) } func TestObjectSizeLinearHistogramIntegration(t *testing.T) { - if testing.Short() { t.Skip("Skipping aerospike integration tests.") } else { @@ -419,7 +414,6 @@ func TestParseHistogramSet(t *testing.T) { a.parseHistogram(stats, "127.0.0.1:3000", "test", "foo", "object-size-linear", "TestNodeName", &acc) acc.AssertContainsTaggedFields(t, "aerospike_histogram_object_size_linear", expectedFields, expectedTags) - } func TestParseHistogramNamespace(t *testing.T) { a := &Aerospike{ @@ -450,7 +444,6 @@ func TestParseHistogramNamespace(t *testing.T) { a.parseHistogram(stats, "127.0.0.1:3000", "test", "", "object-size-linear", "TestNodeName", &acc) acc.AssertContainsTaggedFields(t, "aerospike_histogram_object_size_linear", expectedFields, expectedTags) - } func TestAerospikeParseValue(t *testing.T) { // uint64 with value bigger than int64 max @@ -484,7 +477,6 @@ func FindTagValue(acc *testutil.Accumulator, measurement string, key string, val if ok && v == value { return true } - } } return false diff --git a/plugins/inputs/aliyuncms/aliyuncms.go b/plugins/inputs/aliyuncms/aliyuncms.go index 794f398f7..e5ce38241 100644 --- a/plugins/inputs/aliyuncms/aliyuncms.go +++ b/plugins/inputs/aliyuncms/aliyuncms.go @@ -187,7 +187,6 @@ func (s *AliyunCMS) Description() string { } func (s *AliyunCMS) Init() error { - if s.Project == "" { return errors.New("project is not set") } @@ -275,7 +274,6 @@ func (s *AliyunCMS) Start(telegraf.Accumulator) error { // Gather implements telegraf.Inputs interface func (s *AliyunCMS) Gather(acc telegraf.Accumulator) error { - s.updateWindow(time.Now()) // limit concurrency or we can easily exhaust user connection limit @@ -288,7 +286,6 @@ func (s *AliyunCMS) Gather(acc telegraf.Accumulator) error { s.prepareTagsAndDimensions(metric) wg.Add(len(metric.MetricNames)) for _, metricName := range metric.MetricNames { - <-lmtr.C go func(metricName string, metric *Metric) { defer wg.Done() @@ -308,7 +305,6 @@ func (s *AliyunCMS) Stop() { } func (s *AliyunCMS) updateWindow(relativeTo time.Time) { - //https://help.aliyun.com/document_detail/51936.html?spm=a2c4g.11186623.6.701.54025679zh6wiR //The start and end times are executed in the mode of //opening left and closing right, and startTime cannot be equal @@ -329,7 +325,6 @@ func (s *AliyunCMS) updateWindow(relativeTo time.Time) { // Gather given metric and emit error func (s *AliyunCMS) gatherMetric(acc telegraf.Accumulator, metricName string, metric *Metric) error { - req := cms.CreateDescribeMetricListRequest() req.Period = strconv.FormatInt(int64(s.Period.Duration.Seconds()), 10) req.MetricName = metricName @@ -368,7 +363,6 @@ func (s *AliyunCMS) gatherMetric(acc telegraf.Accumulator, metricName string, me case "instanceId", "BucketName": tags[key] = value.(string) if metric.discoveryTags != nil { //discovery can be not activated - //Skipping data point if discovery data not exist if _, ok := metric.discoveryTags[value.(string)]; !ok && !metric.AllowDataPointWODiscoveryData { @@ -401,7 +395,6 @@ func (s *AliyunCMS) gatherMetric(acc telegraf.Accumulator, metricName string, me //Tag helper func parseTag(tagSpec string, data interface{}) (string, string, error) { - tagKey := tagSpec queryPath := tagSpec @@ -452,9 +445,8 @@ L: } } - if newData || //new data arrives, process it - len(metric.discoveryTags) == 0 { //or this is the first call - + //new data arrives (so process it) or this is the first call + if newData || len(metric.discoveryTags) == 0 { metric.dtLock.Lock() defer metric.dtLock.Unlock() @@ -467,14 +459,12 @@ L: //Preparing tags & dims... for instanceId, elem := range s.discoveryData { - //Start filing tags //Remove old value if exist delete(metric.discoveryTags, instanceId) metric.discoveryTags[instanceId] = make(map[string]string, len(metric.TagsQueryPath)+len(defaulTags)) for _, tagQueryPath := range metric.TagsQueryPath { - tagKey, tagValue, err := parseTag(tagQueryPath, elem) if err != nil { s.Log.Errorf("%v", err) @@ -510,7 +500,6 @@ L: metric.requestDimensions = append( metric.requestDimensions, map[string]string{s.dimensionKey: instanceId}) - } //Get final dimension (need to get full lis of @@ -531,7 +520,6 @@ L: } else { metric.requestDimensionsStr = string(reqDim) } - } } diff --git a/plugins/inputs/aliyuncms/aliyuncms_test.go b/plugins/inputs/aliyuncms/aliyuncms_test.go index 37430bbdd..f0ac60e93 100644 --- a/plugins/inputs/aliyuncms/aliyuncms_test.go +++ b/plugins/inputs/aliyuncms/aliyuncms_test.go @@ -25,7 +25,6 @@ const inputTitle = "inputs.aliyuncms" type mockGatherAliyunCMSClient struct{} func (m *mockGatherAliyunCMSClient) DescribeMetricList(request *cms.DescribeMetricListRequest) (*cms.DescribeMetricListResponse, error) { - resp := new(cms.DescribeMetricListResponse) //switch request.Metric { @@ -221,7 +220,6 @@ func TestUpdateWindow(t *testing.T) { } func TestGatherMetric(t *testing.T) { - plugin := &AliyunCMS{ Project: "acs_slb_dashboard", client: new(mockGatherAliyunCMSClient), @@ -255,13 +253,11 @@ func TestGatherMetric(t *testing.T) { t.Run(tt.name, func(t *testing.T) { var acc telegraf.Accumulator require.EqualError(t, plugin.gatherMetric(acc, tt.metricName, metric), tt.expectedErrorString) - }) } } func TestGather(t *testing.T) { - metric := &Metric{ MetricNames: []string{}, Dimensions: `{"instanceId": "i-abcdefgh123456"}`, @@ -332,7 +328,6 @@ func TestGather(t *testing.T) { } func TestGetDiscoveryDataAllRegions(t *testing.T) { - //test table: tests := []struct { name string @@ -403,8 +398,6 @@ func TestGetDiscoveryDataAllRegions(t *testing.T) { if err != nil { require.EqualError(t, err, tt.expectedErrorString) } - }) } - } diff --git a/plugins/inputs/aliyuncms/discovery.go b/plugins/inputs/aliyuncms/discovery.go index 39e0044b6..904f9d194 100644 --- a/plugins/inputs/aliyuncms/discovery.go +++ b/plugins/inputs/aliyuncms/discovery.go @@ -72,7 +72,6 @@ type discoveryTool struct { //getRpcReqFromDiscoveryRequest - utility function to map between aliyun request primitives //discoveryRequest represents different type of discovery requests func getRpcReqFromDiscoveryRequest(req discoveryRequest) (*requests.RpcRequest, error) { - if reflect.ValueOf(req).Type().Kind() != reflect.Ptr || reflect.ValueOf(req).IsNil() { return nil, errors.Errorf("Not expected type of the discovery request object: %q, %q", reflect.ValueOf(req).Type(), reflect.ValueOf(req).Kind()) @@ -81,7 +80,6 @@ func getRpcReqFromDiscoveryRequest(req discoveryRequest) (*requests.RpcRequest, ptrV := reflect.Indirect(reflect.ValueOf(req)) for i := 0; i < ptrV.NumField(); i++ { - if ptrV.Field(i).Type().String() == "*requests.RpcRequest" { if !ptrV.Field(i).CanInterface() { return nil, errors.Errorf("Can't get interface of %v", ptrV.Field(i)) @@ -323,7 +321,6 @@ func (dt *discoveryTool) parseDiscoveryResponse(resp *responses.CommonResponse) //It should contain the array with discovered data for _, item := range rootKeyVal { - if discData, foundDataItem = item.([]interface{}); foundDataItem { break } @@ -338,7 +335,6 @@ func (dt *discoveryTool) parseDiscoveryResponse(resp *responses.CommonResponse) case "PageNumber": pageNumber = int(val.(float64)) } - } if !foundRootKey { return nil, 0, 0, 0, errors.Errorf("Didn't find root key %q in discovery response", dt.respRootKey) @@ -390,14 +386,11 @@ func (dt *discoveryTool) getDiscoveryData(cli aliyunSdkClient, req *requests.Com } else { return nil, errors.Errorf("Can't parse input data element, not a map[string]interface{} type") } - } return preparedData, nil } - } - } func (dt *discoveryTool) getDiscoveryDataAllRegions(limiter chan bool) (map[string]interface{}, error) { @@ -468,7 +461,6 @@ func (dt *discoveryTool) Start() { case <-dt.done: return case <-ticker.C: - data, err = dt.getDiscoveryDataAllRegions(lmtr.C) if err != nil { dt.lg.Errorf("Can't get discovery data: %v", err) @@ -485,14 +477,12 @@ func (dt *discoveryTool) Start() { //send discovery data in blocking mode dt.dataChan <- data } - } } }() } func (dt *discoveryTool) Stop() { - close(dt.done) //Shutdown timer diff --git a/plugins/inputs/apache/apache.go b/plugins/inputs/apache/apache.go index f6d583170..12edc62cc 100644 --- a/plugins/inputs/apache/apache.go +++ b/plugins/inputs/apache/apache.go @@ -162,7 +162,6 @@ func (n *Apache) gatherScores(data string) map[string]interface{} { var S, R, W, K, D, C, L, G, I int = 0, 0, 0, 0, 0, 0, 0, 0, 0 for _, s := range strings.Split(data, "") { - switch s { case "_": waiting++ diff --git a/plugins/inputs/apcupsd/apcupsd_test.go b/plugins/inputs/apcupsd/apcupsd_test.go index a7dbd2c7d..7ab64ba11 100644 --- a/plugins/inputs/apcupsd/apcupsd_test.go +++ b/plugins/inputs/apcupsd/apcupsd_test.go @@ -102,7 +102,6 @@ func TestConfig(t *testing.T) { } }) } - } func TestApcupsdGather(t *testing.T) { @@ -155,7 +154,6 @@ func TestApcupsdGather(t *testing.T) { ) for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) diff --git a/plugins/inputs/beat/beat_test.go b/plugins/inputs/beat/beat_test.go index 30dd48569..777fe6b98 100644 --- a/plugins/inputs/beat/beat_test.go +++ b/plugins/inputs/beat/beat_test.go @@ -224,5 +224,4 @@ func Test_BeatRequest(test *testing.T) { if err != nil { test.Logf("Can't gather stats") } - } diff --git a/plugins/inputs/cassandra/cassandra.go b/plugins/inputs/cassandra/cassandra.go index ea7001fe3..7f9fe98b2 100644 --- a/plugins/inputs/cassandra/cassandra.go +++ b/plugins/inputs/cassandra/cassandra.go @@ -129,9 +129,7 @@ func (j javaMetric) addTagsFields(out map[string]interface{}) { } } -func addCassandraMetric(mbean string, c cassandraMetric, - values map[string]interface{}) { - +func addCassandraMetric(mbean string, c cassandraMetric, values map[string]interface{}) { tags := make(map[string]string) fields := make(map[string]interface{}) tokens := parseJmxMetricRequest(mbean) @@ -139,11 +137,9 @@ func addCassandraMetric(mbean string, c cassandraMetric, tags["cassandra_host"] = c.host addValuesAsFields(values, fields, tags["mname"]) c.acc.AddFields(tokens["class"]+tokens["type"], fields, tags) - } func (c cassandraMetric) addTagsFields(out map[string]interface{}) { - r := out["request"] tokens := parseJmxMetricRequest(r.(map[string]interface{})["mbean"].(string)) diff --git a/plugins/inputs/cassandra/cassandra_test.go b/plugins/inputs/cassandra/cassandra_test.go index 43a9a0c1e..9b0798207 100644 --- a/plugins/inputs/cassandra/cassandra_test.go +++ b/plugins/inputs/cassandra/cassandra_test.go @@ -198,9 +198,7 @@ func TestHttpJsonJavaMultiType(t *testing.T) { // Test that the proper values are ignored or collected func TestHttp404(t *testing.T) { - - jolokia := genJolokiaClientStub(invalidJSON, 404, Servers, - []string{HeapMetric}) + jolokia := genJolokiaClientStub(invalidJSON, 404, Servers, []string{HeapMetric}) var acc testutil.Accumulator err := acc.GatherError(jolokia.Gather) diff --git a/plugins/inputs/ceph/ceph.go b/plugins/inputs/ceph/ceph.go index 5a820a238..b4e83844f 100644 --- a/plugins/inputs/ceph/ceph.go +++ b/plugins/inputs/ceph/ceph.go @@ -211,17 +211,14 @@ var findSockets = func(c *Ceph) ([]*socket, error) { if strings.HasPrefix(f, c.OsdPrefix) { sockType = typeOsd sockPrefix = osdPrefix - } if strings.HasPrefix(f, c.MdsPrefix) { sockType = typeMds sockPrefix = mdsPrefix - } if strings.HasPrefix(f, c.RgwPrefix) { sockType = typeRgw sockPrefix = rgwPrefix - } if sockType == typeOsd || sockType == typeMon || sockType == typeMds || sockType == typeRgw { diff --git a/plugins/inputs/ceph/ceph_test.go b/plugins/inputs/ceph/ceph_test.go index f6cf8e8a9..e46a18049 100644 --- a/plugins/inputs/ceph/ceph_test.go +++ b/plugins/inputs/ceph/ceph_test.go @@ -105,7 +105,6 @@ func TestGather(t *testing.T) { acc := &testutil.Accumulator{} c := &Ceph{} c.Gather(acc) - } func TestFindSockets(t *testing.T) { diff --git a/plugins/inputs/chrony/chrony_test.go b/plugins/inputs/chrony/chrony_test.go index a5fd9dd02..4b8ad85cc 100644 --- a/plugins/inputs/chrony/chrony_test.go +++ b/plugins/inputs/chrony/chrony_test.go @@ -49,7 +49,6 @@ func TestGather(t *testing.T) { t.Fatal(err) } acc.AssertContainsTaggedFields(t, "chrony", fields, tags) - } // fackeExecCommand is a helper function that mock @@ -102,7 +101,6 @@ Leap status : Not synchronized } else { fmt.Fprint(os.Stdout, "command not found") os.Exit(1) - } os.Exit(0) } diff --git a/plugins/inputs/cisco_telemetry_mdt/cisco_telemetry_mdt_test.go b/plugins/inputs/cisco_telemetry_mdt/cisco_telemetry_mdt_test.go index ea200bc74..f967044da 100644 --- a/plugins/inputs/cisco_telemetry_mdt/cisco_telemetry_mdt_test.go +++ b/plugins/inputs/cisco_telemetry_mdt/cisco_telemetry_mdt_test.go @@ -588,5 +588,4 @@ func TestGRPCDialoutMultiple(t *testing.T) { tags = map[string]string{"path": "type:model/other/path", "name": "str", "source": "hostname", "subscription": "subscription"} fields = map[string]interface{}{"value": int64(-1)} acc.AssertContainsTaggedFields(t, "other", fields, tags) - } diff --git a/plugins/inputs/clickhouse/clickhouse.go b/plugins/inputs/clickhouse/clickhouse.go index 187ead5cf..866ddeb8c 100644 --- a/plugins/inputs/clickhouse/clickhouse.go +++ b/plugins/inputs/clickhouse/clickhouse.go @@ -195,7 +195,6 @@ func (ch *ClickHouse) Gather(acc telegraf.Accumulator) (err error) { } for _, conn := range connects { - metricsFuncs := []func(acc telegraf.Accumulator, conn *connect) error{ ch.tables, ch.zookeeper, @@ -212,7 +211,6 @@ func (ch *ClickHouse) Gather(acc telegraf.Accumulator) (err error) { if err := metricFunc(acc, &conn); err != nil { acc.AddError(err) } - } for metric := range commonMetrics { @@ -342,7 +340,6 @@ func (ch *ClickHouse) replicationQueue(acc telegraf.Accumulator, conn *connect) } func (ch *ClickHouse) detachedParts(acc telegraf.Accumulator, conn *connect) error { - var detachedParts []struct { DetachedParts chUInt64 `json:"detached_parts"` } @@ -363,7 +360,6 @@ func (ch *ClickHouse) detachedParts(acc telegraf.Accumulator, conn *connect) err } func (ch *ClickHouse) dictionaries(acc telegraf.Accumulator, conn *connect) error { - var brokenDictionaries []struct { Origin string `json:"origin"` BytesAllocated chUInt64 `json:"bytes_allocated"` @@ -397,7 +393,6 @@ func (ch *ClickHouse) dictionaries(acc telegraf.Accumulator, conn *connect) erro } func (ch *ClickHouse) mutations(acc telegraf.Accumulator, conn *connect) error { - var mutationsStatus []struct { Failed chUInt64 `json:"failed"` Running chUInt64 `json:"running"` @@ -424,7 +419,6 @@ func (ch *ClickHouse) mutations(acc telegraf.Accumulator, conn *connect) error { } func (ch *ClickHouse) disks(acc telegraf.Accumulator, conn *connect) error { - var disksStatus []struct { Name string `json:"name"` Path string `json:"path"` @@ -448,14 +442,12 @@ func (ch *ClickHouse) disks(acc telegraf.Accumulator, conn *connect) error { }, tags, ) - } return nil } func (ch *ClickHouse) processes(acc telegraf.Accumulator, conn *connect) error { - var processesStats []struct { QueryType string `json:"query_type"` Percentile50 float64 `json:"p50"` @@ -479,7 +471,6 @@ func (ch *ClickHouse) processes(acc telegraf.Accumulator, conn *connect) error { }, tags, ) - } return nil diff --git a/plugins/inputs/clickhouse/clickhouse_test.go b/plugins/inputs/clickhouse/clickhouse_test.go index 68a443844..c69c455b9 100644 --- a/plugins/inputs/clickhouse/clickhouse_test.go +++ b/plugins/inputs/clickhouse/clickhouse_test.go @@ -583,5 +583,4 @@ func TestAutoDiscovery(t *testing.T) { ) defer ts.Close() ch.Gather(acc) - } diff --git a/plugins/inputs/couchbase/couchbase_test.go b/plugins/inputs/couchbase/couchbase_test.go index df7f1b4c1..66a1d08ab 100644 --- a/plugins/inputs/couchbase/couchbase_test.go +++ b/plugins/inputs/couchbase/couchbase_test.go @@ -41,7 +41,6 @@ func TestGatherServer(t *testing.T) { } func TestSanitizeURI(t *testing.T) { - var sanitizeTest = []struct { input string expected string diff --git a/plugins/inputs/csgo/csgo.go b/plugins/inputs/csgo/csgo.go index fe8296266..0fa18cab2 100644 --- a/plugins/inputs/csgo/csgo.go +++ b/plugins/inputs/csgo/csgo.go @@ -74,8 +74,8 @@ func init() { func (s *CSGO) gatherServer( server []string, request func(string, string) (string, error), - acc telegraf.Accumulator) error { - + acc telegraf.Accumulator, +) error { if len(server) != 2 { return errors.New("incorrect server config") } diff --git a/plugins/inputs/dcos/client.go b/plugins/inputs/dcos/client.go index 8f171638a..32eab8086 100644 --- a/plugins/inputs/dcos/client.go +++ b/plugins/inputs/dcos/client.go @@ -229,7 +229,6 @@ func (c *ClusterClient) GetContainers(ctx context.Context, node string) ([]Conta containers := make([]Container, 0, len(list)) for _, c := range list { containers = append(containers, Container{ID: c}) - } return containers, nil diff --git a/plugins/inputs/dcos/client_test.go b/plugins/inputs/dcos/client_test.go index 0b7772dcc..ece4b178f 100644 --- a/plugins/inputs/dcos/client_test.go +++ b/plugins/inputs/dcos/client_test.go @@ -142,7 +142,6 @@ func TestGetSummary(t *testing.T) { require.Equal(t, tt.expectedValue, summary) }) } - } func TestGetNodeMetrics(t *testing.T) { @@ -184,7 +183,6 @@ func TestGetNodeMetrics(t *testing.T) { require.Equal(t, tt.expectedValue, m) }) } - } func TestGetContainerMetrics(t *testing.T) { @@ -226,5 +224,4 @@ func TestGetContainerMetrics(t *testing.T) { require.Equal(t, tt.expectedValue, m) }) } - } diff --git a/plugins/inputs/dcos/dcos_test.go b/plugins/inputs/dcos/dcos_test.go index 3914fa577..828fd0af6 100644 --- a/plugins/inputs/dcos/dcos_test.go +++ b/plugins/inputs/dcos/dcos_test.go @@ -203,7 +203,6 @@ func TestAddNodeMetrics(t *testing.T) { } }) } - } func TestAddContainerMetrics(t *testing.T) { diff --git a/plugins/inputs/diskio/diskio.go b/plugins/inputs/diskio/diskio.go index 5250b704a..c586233a8 100644 --- a/plugins/inputs/diskio/diskio.go +++ b/plugins/inputs/diskio/diskio.go @@ -104,7 +104,6 @@ func (d *DiskIO) Gather(acc telegraf.Accumulator) error { } for _, io := range diskio { - match := false if d.deviceFilter != nil && d.deviceFilter.Match(io.Name) { match = true diff --git a/plugins/inputs/diskio/diskio_linux_test.go b/plugins/inputs/diskio/diskio_linux_test.go index 4d7dc5c82..9362b195c 100644 --- a/plugins/inputs/diskio/diskio_linux_test.go +++ b/plugins/inputs/diskio/diskio_linux_test.go @@ -71,7 +71,6 @@ func TestDiskInfo(t *testing.T) { assert.Equal(t, "myval1", di["MY_PARAM_1"]) assert.Equal(t, "myval2", di["MY_PARAM_2"]) assert.Equal(t, "/dev/foo/bar/devlink /dev/foo/bar/devlink1", di["DEVLINKS"]) - // unfortunately we can't adjust mtime on /dev/null to test cache invalidation } diff --git a/plugins/inputs/disque/disque.go b/plugins/inputs/disque/disque.go index 021e865bf..6cdff83ee 100644 --- a/plugins/inputs/disque/disque.go +++ b/plugins/inputs/disque/disque.go @@ -102,7 +102,6 @@ const defaultPort = "7711" func (d *Disque) gatherServer(addr *url.URL, acc telegraf.Accumulator) error { if d.c == nil { - _, _, err := net.SplitHostPort(addr.Host) if err != nil { addr.Host = addr.Host + ":" + defaultPort diff --git a/plugins/inputs/docker/docker_test.go b/plugins/inputs/docker/docker_test.go index 3272abec0..b0c9f9791 100644 --- a/plugins/inputs/docker/docker_test.go +++ b/plugins/inputs/docker/docker_test.go @@ -1122,7 +1122,6 @@ func TestHostnameFromID(t *testing.T) { } }) } - } func Test_parseContainerStatsPerDeviceAndTotal(t *testing.T) { @@ -1269,7 +1268,6 @@ func Test_parseContainerStatsPerDeviceAndTotal(t *testing.T) { []string{"docker_container_cpu", "docker_container_net", "docker_container_blkio"}) }) testutil.RequireMetricsEqual(t, tt.expected, actual, testutil.OnlyTags(), testutil.SortMetrics()) - }) } } @@ -1360,7 +1358,6 @@ func TestDocker_Init(t *testing.T) { t.Errorf("Total include: got '%v', want '%v'", d.TotalInclude, tt.wantTotalInclude) } } - }) } } diff --git a/plugins/inputs/dovecot/dovecot.go b/plugins/inputs/dovecot/dovecot.go index 6c85acadc..b9875079d 100644 --- a/plugins/inputs/dovecot/dovecot.go +++ b/plugins/inputs/dovecot/dovecot.go @@ -110,7 +110,6 @@ func (d *Dovecot) gatherServer(addr string, acc telegraf.Accumulator, qtype stri } func gatherStats(buf *bytes.Buffer, acc telegraf.Accumulator, host string, qtype string) error { - lines := strings.Split(buf.String(), "\n") head := strings.Split(lines[0], "\t") vals := lines[1:] @@ -169,13 +168,11 @@ func splitSec(tm string) (sec int64, msec int64) { } func timeParser(tm string) time.Time { - sec, msec := splitSec(tm) return time.Unix(sec, msec) } func secParser(tm string) float64 { - sec, msec := splitSec(tm) return float64(sec) + (float64(msec) / 1000000.0) } diff --git a/plugins/inputs/dovecot/dovecot_test.go b/plugins/inputs/dovecot/dovecot_test.go index 86efdbb4f..97c1d2f88 100644 --- a/plugins/inputs/dovecot/dovecot_test.go +++ b/plugins/inputs/dovecot/dovecot_test.go @@ -10,7 +10,6 @@ import ( ) func TestDovecotIntegration(t *testing.T) { - if testing.Short() { t.Skip("Skipping integration test in short mode") } @@ -103,7 +102,6 @@ func TestDovecotIntegration(t *testing.T) { require.NoError(t, err) acc.AssertContainsTaggedFields(t, "dovecot", fields, tags) - } const sampleGlobal = `reset_timestamp last_update num_logins num_cmds num_connected_sessions user_cpu sys_cpu clock_time min_faults maj_faults vol_cs invol_cs disk_input disk_output read_count read_bytes write_count write_bytes mail_lookup_path mail_lookup_attr mail_read_count mail_read_bytes mail_cache_hits diff --git a/plugins/inputs/ecs/client.go b/plugins/inputs/ecs/client.go index d7ce10cb2..ac7ed2e1b 100644 --- a/plugins/inputs/ecs/client.go +++ b/plugins/inputs/ecs/client.go @@ -152,7 +152,6 @@ func (c *EcsClient) ContainerStats() (map[string]types.StatsJSON, error) { // PollSync executes Task and ContainerStats in parallel. If both succeed, both structs are returned. // If either errors, a single error is returned. func PollSync(c Client) (*Task, map[string]types.StatsJSON, error) { - var task *Task var stats map[string]types.StatsJSON var err error diff --git a/plugins/inputs/ecs/client_test.go b/plugins/inputs/ecs/client_test.go index 333aec80c..2f37ca0cf 100644 --- a/plugins/inputs/ecs/client_test.go +++ b/plugins/inputs/ecs/client_test.go @@ -27,7 +27,6 @@ func (p *pollMock) ContainerStats() (map[string]types.StatsJSON, error) { } func TestEcsClient_PollSync(t *testing.T) { - tests := []struct { name string mock *pollMock diff --git a/plugins/inputs/ecs/stats.go b/plugins/inputs/ecs/stats.go index d2a8ee5d3..13d9aa3bc 100644 --- a/plugins/inputs/ecs/stats.go +++ b/plugins/inputs/ecs/stats.go @@ -284,7 +284,6 @@ func blkstats(id string, stats types.StatsJSON, acc telegraf.Accumulator, tags m } else { totalStatMap[field] = uintV } - } } diff --git a/plugins/inputs/elasticsearch/elasticsearch.go b/plugins/inputs/elasticsearch/elasticsearch.go index 33755c5ce..f8064e606 100644 --- a/plugins/inputs/elasticsearch/elasticsearch.go +++ b/plugins/inputs/elasticsearch/elasticsearch.go @@ -277,7 +277,6 @@ func (e *Elasticsearch) Gather(acc telegraf.Accumulator) error { e.serverInfoMutex.Lock() e.serverInfo[s] = info e.serverInfoMutex.Unlock() - }(serv, acc) } wgC.Wait() @@ -640,7 +639,6 @@ func (e *Elasticsearch) gatherSingleIndexStats(name string, index indexStat, now if e.IndicesLevel == "shards" { for shardNumber, shards := range index.Shards { for _, shard := range shards { - // Get Shard Stats flattened := jsonparser.JSONFlattener{} err := flattened.FullFlattenJSON("", shard, true, true) diff --git a/plugins/inputs/exec/exec.go b/plugins/inputs/exec/exec.go index adb16c953..26e2ab0ba 100644 --- a/plugins/inputs/exec/exec.go +++ b/plugins/inputs/exec/exec.go @@ -137,7 +137,6 @@ func removeCarriageReturns(b bytes.Buffer) bytes.Buffer { b = buf } return b - } func (e *Exec) ProcessCommand(command string, acc telegraf.Accumulator, wg *sync.WaitGroup) { diff --git a/plugins/inputs/execd/execd_test.go b/plugins/inputs/execd/execd_test.go index 6cb254eb5..ab67af0ab 100644 --- a/plugins/inputs/execd/execd_test.go +++ b/plugins/inputs/execd/execd_test.go @@ -186,5 +186,4 @@ func runCounterProgram() { } fmt.Fprint(os.Stdout, string(b)) } - } diff --git a/plugins/inputs/fibaro/fibaro.go b/plugins/inputs/fibaro/fibaro.go index 62889cc8d..20b993576 100644 --- a/plugins/inputs/fibaro/fibaro.go +++ b/plugins/inputs/fibaro/fibaro.go @@ -121,7 +121,6 @@ func (f *Fibaro) getJSON(path string, dataStruct interface{}) error { // Gather fetches all required information to output metrics func (f *Fibaro) Gather(acc telegraf.Accumulator) error { - if f.client == nil { f.client = &http.Client{ Transport: &http.Transport{ diff --git a/plugins/inputs/filecount/filecount.go b/plugins/inputs/filecount/filecount.go index c2b572c12..87c980754 100644 --- a/plugins/inputs/filecount/filecount.go +++ b/plugins/inputs/filecount/filecount.go @@ -292,7 +292,6 @@ func (fc *FileCount) initGlobPaths(acc telegraf.Accumulator) { fc.globPaths = append(fc.globPaths, *glob) } } - } func NewFileCount() *FileCount { diff --git a/plugins/inputs/filecount/filecount_test.go b/plugins/inputs/filecount/filecount_test.go index 39bbafb36..2136c348d 100644 --- a/plugins/inputs/filecount/filecount_test.go +++ b/plugins/inputs/filecount/filecount_test.go @@ -229,9 +229,7 @@ func getFakeFileSystem(basePath string) fakeFileSystem { basePath + "/subdir/nested2/qux": {name: "qux", filemode: uint32(fmask), modtime: mtime, size: int64(400)}, } - fs := fakeFileSystem{files: fileList} - return fs - + return fakeFileSystem{files: fileList} } func fileCountEquals(t *testing.T, fc FileCount, expectedCount int, expectedSize int) { diff --git a/plugins/inputs/filecount/filesystem_helpers.go b/plugins/inputs/filecount/filesystem_helpers.go index 2bd6c0951..f43bb4ad5 100644 --- a/plugins/inputs/filecount/filesystem_helpers.go +++ b/plugins/inputs/filecount/filesystem_helpers.go @@ -69,5 +69,4 @@ func (f fakeFileSystem) Stat(name string) (os.FileInfo, error) { return fakeInfo, nil } return nil, &os.PathError{Op: "Stat", Path: name, Err: errors.New("No such file or directory")} - } diff --git a/plugins/inputs/filecount/filesystem_helpers_test.go b/plugins/inputs/filecount/filesystem_helpers_test.go index 62e7e2f81..220350072 100644 --- a/plugins/inputs/filecount/filesystem_helpers_test.go +++ b/plugins/inputs/filecount/filesystem_helpers_test.go @@ -89,7 +89,5 @@ func getTestFileSystem() fakeFileSystem { "/testdata/foo": {name: "foo", filemode: uint32(fmask), modtime: mtime}, } - fs := fakeFileSystem{files: fileList} - return fs - + return fakeFileSystem{files: fileList} } diff --git a/plugins/inputs/fireboard/fireboard.go b/plugins/inputs/fireboard/fireboard.go index a92930aae..c9a79396e 100644 --- a/plugins/inputs/fireboard/fireboard.go +++ b/plugins/inputs/fireboard/fireboard.go @@ -69,7 +69,6 @@ func (r *Fireboard) Description() string { // Init the things func (r *Fireboard) Init() error { - if len(r.AuthToken) == 0 { return fmt.Errorf("You must specify an authToken") } @@ -88,7 +87,6 @@ func (r *Fireboard) Init() error { // Gather Reads stats from all configured servers. func (r *Fireboard) Gather(acc telegraf.Accumulator) error { - // Perform the GET request to the fireboard servers req, err := http.NewRequest("GET", r.URL, nil) if err != nil { diff --git a/plugins/inputs/fluentd/fluentd.go b/plugins/inputs/fluentd/fluentd.go index 7d4a0cd5e..1d23259fa 100644 --- a/plugins/inputs/fluentd/fluentd.go +++ b/plugins/inputs/fluentd/fluentd.go @@ -81,14 +81,12 @@ func (h *Fluentd) SampleConfig() string { return sampleConfig } // Gather - Main code responsible for gathering, processing and creating metrics func (h *Fluentd) Gather(acc telegraf.Accumulator) error { - _, err := url.Parse(h.Endpoint) if err != nil { return fmt.Errorf("Invalid URL \"%s\"", h.Endpoint) } if h.client == nil { - tr := &http.Transport{ ResponseHeaderTimeout: time.Duration(3 * time.Second), } @@ -127,7 +125,6 @@ func (h *Fluentd) Gather(acc telegraf.Accumulator) error { // Go through all plugins one by one for _, p := range dataPoints { - skip := false // Check if this specific type was excluded in configuration @@ -149,7 +146,6 @@ func (h *Fluentd) Gather(acc telegraf.Accumulator) error { if p.BufferQueueLength != nil { tmpFields["buffer_queue_length"] = *p.BufferQueueLength - } if p.RetryCount != nil { tmpFields["retry_count"] = *p.RetryCount diff --git a/plugins/inputs/fluentd/fluentd_test.go b/plugins/inputs/fluentd/fluentd_test.go index c7699c338..795b6dbcf 100644 --- a/plugins/inputs/fluentd/fluentd_test.go +++ b/plugins/inputs/fluentd/fluentd_test.go @@ -111,14 +111,12 @@ var ( ) func Test_parse(t *testing.T) { - t.Log("Testing parser function") _, err := parse([]byte(sampleJSON)) if err != nil { t.Error(err) } - } func Test_Gather(t *testing.T) { @@ -159,5 +157,4 @@ func Test_Gather(t *testing.T) { assert.Equal(t, *expectedOutput[1].RetryCount, acc.Metrics[1].Fields["retry_count"]) assert.Equal(t, *expectedOutput[1].BufferQueueLength, acc.Metrics[1].Fields["buffer_queue_length"]) assert.Equal(t, *expectedOutput[1].BufferTotalQueuedSize, acc.Metrics[1].Fields["buffer_total_queued_size"]) - } diff --git a/plugins/inputs/gnmi/gnmi.go b/plugins/inputs/gnmi/gnmi.go index 5e99092f8..5d4c80edd 100644 --- a/plugins/inputs/gnmi/gnmi.go +++ b/plugins/inputs/gnmi/gnmi.go @@ -403,7 +403,6 @@ func (c *GNMI) handlePath(path *gnmi.Path, tags map[string]string, prefix string } else { tags[key] = val } - } } } diff --git a/plugins/inputs/haproxy/haproxy.go b/plugins/inputs/haproxy/haproxy.go index 73cf9d334..a3fe09072 100644 --- a/plugins/inputs/haproxy/haproxy.go +++ b/plugins/inputs/haproxy/haproxy.go @@ -79,7 +79,6 @@ func (h *haproxy) Gather(acc telegraf.Accumulator) error { endpoints := make([]string, 0, len(h.Servers)) for _, endpoint := range h.Servers { - if strings.HasPrefix(endpoint, "http") { endpoints = append(endpoints, endpoint) continue diff --git a/plugins/inputs/hddtemp/hddtemp_test.go b/plugins/inputs/hddtemp/hddtemp_test.go index f299c2ac6..6d7301bbc 100644 --- a/plugins/inputs/hddtemp/hddtemp_test.go +++ b/plugins/inputs/hddtemp/hddtemp_test.go @@ -27,7 +27,6 @@ func (h *mockFetcher) Fetch(address string) ([]hddtemp.Disk, error) { Unit: "C", }, }, nil - } func newMockFetcher() *mockFetcher { return &mockFetcher{} @@ -79,5 +78,4 @@ func TestFetch(t *testing.T) { for _, test := range tests { acc.AssertContainsTaggedFields(t, "hddtemp", test.fields, test.tags) } - } diff --git a/plugins/inputs/http_listener_v2/http_listener_v2.go b/plugins/inputs/http_listener_v2/http_listener_v2.go index 41ce35df5..b88e1eb8c 100644 --- a/plugins/inputs/http_listener_v2/http_listener_v2.go +++ b/plugins/inputs/http_listener_v2/http_listener_v2.go @@ -313,7 +313,6 @@ func (h *HTTPListenerV2) authenticateIfSet(handler http.HandlerFunc, res http.Re if !ok || subtle.ConstantTimeCompare([]byte(reqUsername), []byte(h.BasicUsername)) != 1 || subtle.ConstantTimeCompare([]byte(reqPassword), []byte(h.BasicPassword)) != 1 { - http.Error(res, "Unauthorized.", http.StatusUnauthorized) return } diff --git a/plugins/inputs/infiniband/infiniband_test.go b/plugins/inputs/infiniband/infiniband_test.go index 57e8ad4da..7f747eb5f 100644 --- a/plugins/inputs/infiniband/infiniband_test.go +++ b/plugins/inputs/infiniband/infiniband_test.go @@ -130,5 +130,4 @@ func TestInfiniband(t *testing.T) { addStats("m1x5_0", "1", sampleRdmastatsEntries, &acc) acc.AssertContainsTaggedFields(t, "infiniband", fields, tags) - } diff --git a/plugins/inputs/influxdb_listener/influxdb_listener.go b/plugins/inputs/influxdb_listener/influxdb_listener.go index 8d87b38f8..de814a198 100644 --- a/plugins/inputs/influxdb_listener/influxdb_listener.go +++ b/plugins/inputs/influxdb_listener/influxdb_listener.go @@ -327,7 +327,6 @@ func (h *InfluxDBListener) handleWrite() http.HandlerFunc { } h.acc.AddMetric(m) - } if err != influx.EOF { h.Log.Debugf("Error parsing the request body: %v", err.Error()) diff --git a/plugins/inputs/intel_powerstat/rapl.go b/plugins/inputs/intel_powerstat/rapl.go index 17d66ff3a..1e4b465fd 100644 --- a/plugins/inputs/intel_powerstat/rapl.go +++ b/plugins/inputs/intel_powerstat/rapl.go @@ -92,7 +92,6 @@ func (r *raplServiceImpl) getConstraintMaxPowerWatts(socketID string) (float64, socketMaxPower, _, err := r.fs.readFileToFloat64(socketMaxPowerFile) return convertMicroWattToWatt(socketMaxPower), err - } func (r *raplServiceImpl) prepareData() { @@ -176,8 +175,8 @@ func (r *raplServiceImpl) findDramFolder(raplFolders []string, socketID string) } func (r *raplServiceImpl) calculateData(socketID string, socketEnergyUjFile io.Reader, dramEnergyUjFile io.Reader, - socketMaxEnergyUjFile io.Reader, dramMaxEnergyUjFile io.Reader) error { - + socketMaxEnergyUjFile io.Reader, dramMaxEnergyUjFile io.Reader, +) error { newSocketEnergy, _, err := r.readEnergyInJoules(socketEnergyUjFile) if err != nil { return err diff --git a/plugins/inputs/intel_rdt/intel_rdt.go b/plugins/inputs/intel_rdt/intel_rdt.go index 3b56d76e7..ba47234a7 100644 --- a/plugins/inputs/intel_rdt/intel_rdt.go +++ b/plugins/inputs/intel_rdt/intel_rdt.go @@ -298,11 +298,9 @@ func (r *IntelRDT) processOutput(cmdReader io.ReadCloser, processesPIDsAssociati */ toOmit := pqosInitOutputLinesNumber - // omit first measurements which are zeroes - if len(r.parsedCores) != 0 { + if len(r.parsedCores) != 0 { // omit first measurements which are zeroes toOmit = toOmit + len(r.parsedCores) - // specify how many lines should pass before stopping - } else if len(processesPIDsAssociation) != 0 { + } else if len(processesPIDsAssociation) != 0 { // specify how many lines should pass before stopping toOmit = toOmit + len(processesPIDsAssociation) } for omitCounter := 0; omitCounter < toOmit; omitCounter++ { diff --git a/plugins/inputs/ipmi_sensor/ipmi_test.go b/plugins/inputs/ipmi_sensor/ipmi_test.go index 55a1da6b1..422d2ab38 100644 --- a/plugins/inputs/ipmi_sensor/ipmi_test.go +++ b/plugins/inputs/ipmi_sensor/ipmi_test.go @@ -378,7 +378,6 @@ OS RealTime Mod | 0x00 | ok } else { fmt.Fprint(os.Stdout, "command not found") os.Exit(1) - } os.Exit(0) } @@ -573,7 +572,6 @@ Power Supply 1 | 03h | ok | 10.1 | 110 Watts, Presence detected } else { fmt.Fprint(os.Stdout, "command not found") os.Exit(1) - } os.Exit(0) } diff --git a/plugins/inputs/jenkins/jenkins.go b/plugins/inputs/jenkins/jenkins.go index 78820da55..a4b34baaa 100644 --- a/plugins/inputs/jenkins/jenkins.go +++ b/plugins/inputs/jenkins/jenkins.go @@ -197,7 +197,6 @@ func (j *Jenkins) initialize(client *http.Client) error { } func (j *Jenkins) gatherNodeData(n node, acc telegraf.Accumulator) error { - tags := map[string]string{} if n.DisplayName == "" { return fmt.Errorf("error empty node name") @@ -249,7 +248,6 @@ func (j *Jenkins) gatherNodeData(n node, acc telegraf.Accumulator) error { } func (j *Jenkins) gatherNodesData(acc telegraf.Accumulator) { - nodeResp, err := j.client.getAllNodes(context.Background()) if err != nil { acc.AddError(err) diff --git a/plugins/inputs/jenkins/jenkins_test.go b/plugins/inputs/jenkins/jenkins_test.go index ffac5d830..f877c700d 100644 --- a/plugins/inputs/jenkins/jenkins_test.go +++ b/plugins/inputs/jenkins/jenkins_test.go @@ -846,7 +846,6 @@ func TestGatherJobs(t *testing.T) { } } } - } }) } diff --git a/plugins/inputs/jolokia/jolokia.go b/plugins/inputs/jolokia/jolokia.go index 5c72ba713..ed5922dda 100644 --- a/plugins/inputs/jolokia/jolokia.go +++ b/plugins/inputs/jolokia/jolokia.go @@ -217,7 +217,6 @@ func (j *Jolokia) prepareRequest(server Server, metrics []Metric) (*http.Request } jolokiaURL = proxyURL - } else { serverURL, err := url.Parse("http://" + server.Host + ":" + server.Port + context) if err != nil { diff --git a/plugins/inputs/jolokia/jolokia_test.go b/plugins/inputs/jolokia/jolokia_test.go index 88f2ab6a1..3f05274eb 100644 --- a/plugins/inputs/jolokia/jolokia_test.go +++ b/plugins/inputs/jolokia/jolokia_test.go @@ -239,9 +239,7 @@ func TestHttpJsonThreeLevelMultiValue(t *testing.T) { // Test that the proper values are ignored or collected func TestHttp404(t *testing.T) { - - jolokia := genJolokiaClientStub(invalidJSON, 404, Servers, - []Metric{UsedHeapMetric}) + jolokia := genJolokiaClientStub(invalidJSON, 404, Servers, []Metric{UsedHeapMetric}) var acc testutil.Accumulator acc.SetDebug(true) @@ -254,9 +252,7 @@ func TestHttp404(t *testing.T) { // Test that the proper values are ignored or collected func TestHttpInvalidJson(t *testing.T) { - - jolokia := genJolokiaClientStub(invalidJSON, 200, Servers, - []Metric{UsedHeapMetric}) + jolokia := genJolokiaClientStub(invalidJSON, 200, Servers, []Metric{UsedHeapMetric}) var acc testutil.Accumulator acc.SetDebug(true) diff --git a/plugins/inputs/jolokia2/gatherer.go b/plugins/inputs/jolokia2/gatherer.go index f24918998..7ee8438dd 100644 --- a/plugins/inputs/jolokia2/gatherer.go +++ b/plugins/inputs/jolokia2/gatherer.go @@ -195,7 +195,6 @@ func tagSetsMatch(a, b map[string]string) bool { func makeReadRequests(metrics []Metric) []ReadRequest { var requests []ReadRequest for _, metric := range metrics { - if len(metric.Paths) == 0 { requests = append(requests, ReadRequest{ Mbean: metric.Mbean, diff --git a/plugins/inputs/jolokia2/jolokia_agent.go b/plugins/inputs/jolokia2/jolokia_agent.go index 58b67ce5a..2489ac19d 100644 --- a/plugins/inputs/jolokia2/jolokia_agent.go +++ b/plugins/inputs/jolokia2/jolokia_agent.go @@ -83,9 +83,8 @@ func (ja *JolokiaAgent) Gather(acc telegraf.Accumulator) error { err := ja.gatherer.Gather(client, acc) if err != nil { - acc.AddError(fmt.Errorf("Unable to gather metrics for %s: %v", client.URL, err)) + acc.AddError(fmt.Errorf("unable to gather metrics for %s: %v", client.URL, err)) } - }(client) } diff --git a/plugins/inputs/jolokia2/point_builder.go b/plugins/inputs/jolokia2/point_builder.go index f5ae1d314..c1b985155 100644 --- a/plugins/inputs/jolokia2/point_builder.go +++ b/plugins/inputs/jolokia2/point_builder.go @@ -40,7 +40,6 @@ func (pb *pointBuilder) Build(mbean string, value interface{}) []point { points := make([]point, 0) for mbean, value := range valueMap { - points = append(points, point{ Tags: pb.extractTags(mbean), Fields: pb.extractFields(mbean, value), @@ -99,13 +98,11 @@ func (pb *pointBuilder) extractFields(mbean string, value interface{}) map[strin // if there were no attributes requested, // then the keys are attributes pb.fillFields("", valueMap, fieldMap) - } else if len(pb.objectAttributes) == 1 { // if there was a single attribute requested, // then the keys are the attribute's properties fieldName := pb.formatFieldName(pb.objectAttributes[0], pb.objectPath) pb.fillFields(fieldName, valueMap, fieldMap) - } else { // if there were multiple attributes requested, // then the keys are the attribute names @@ -199,7 +196,6 @@ func (pb *pointBuilder) applySubstitutions(mbean string, fieldMap map[string]int properties := makePropertyMap(mbean) for i, subKey := range pb.substitutions[1:] { - symbol := fmt.Sprintf("$%d", i+1) substitution := properties[subKey] diff --git a/plugins/inputs/jti_openconfig_telemetry/openconfig_telemetry.go b/plugins/inputs/jti_openconfig_telemetry/openconfig_telemetry.go index acc56b187..e423588ee 100644 --- a/plugins/inputs/jti_openconfig_telemetry/openconfig_telemetry.go +++ b/plugins/inputs/jti_openconfig_telemetry/openconfig_telemetry.go @@ -272,7 +272,6 @@ func (m *OpenConfigTelemetry) splitSensorConfig() int { m.sensorsConfig = append(m.sensorsConfig, sensorConfig{ measurementName: measurementName, pathList: pathlist, }) - } return len(m.sensorsConfig) diff --git a/plugins/inputs/kapacitor/kapacitor.go b/plugins/inputs/kapacitor/kapacitor.go index ecb99877d..ac037a183 100644 --- a/plugins/inputs/kapacitor/kapacitor.go +++ b/plugins/inputs/kapacitor/kapacitor.go @@ -216,7 +216,6 @@ func (k *Kapacitor) gatherURL( if s.Kapacitor != nil { for _, obj := range *s.Kapacitor { - // Strip out high-cardinality or duplicative tags excludeTags := []string{"host", "cluster_id", "server_id"} for _, key := range excludeTags { diff --git a/plugins/inputs/kernel/kernel.go b/plugins/inputs/kernel/kernel.go index cd682c779..484c819cf 100644 --- a/plugins/inputs/kernel/kernel.go +++ b/plugins/inputs/kernel/kernel.go @@ -35,7 +35,6 @@ func (k *Kernel) Description() string { func (k *Kernel) SampleConfig() string { return "" } func (k *Kernel) Gather(acc telegraf.Accumulator) error { - data, err := k.getProcStat() if err != nil { return err diff --git a/plugins/inputs/kernel_vmstat/kernel_vmstat.go b/plugins/inputs/kernel_vmstat/kernel_vmstat.go index 7ebb9ab25..7b0292937 100644 --- a/plugins/inputs/kernel_vmstat/kernel_vmstat.go +++ b/plugins/inputs/kernel_vmstat/kernel_vmstat.go @@ -35,7 +35,6 @@ func (k *KernelVmstat) Gather(acc telegraf.Accumulator) error { dataFields := bytes.Fields(data) for i, field := range dataFields { - // dataFields is an array of {"stat1_name", "stat1_value", "stat2_name", // "stat2_value", ...} // We only want the even number index as that contain the stat name. diff --git a/plugins/inputs/kibana/kibana.go b/plugins/inputs/kibana/kibana.go index 83523eb37..1626f78a2 100644 --- a/plugins/inputs/kibana/kibana.go +++ b/plugins/inputs/kibana/kibana.go @@ -183,7 +183,6 @@ func (k *Kibana) createHTTPClient() (*http.Client, error) { } func (k *Kibana) gatherKibanaStatus(baseURL string, acc telegraf.Accumulator) error { - kibanaStatus := &kibanaStatus{} url := baseURL + statusPath @@ -229,9 +228,7 @@ func (k *Kibana) gatherKibanaStatus(baseURL string, acc telegraf.Accumulator) er fields["heap_max_bytes"] = kibanaStatus.Metrics.Process.Mem.HeapMaxInBytes fields["heap_total_bytes"] = kibanaStatus.Metrics.Process.Mem.HeapMaxInBytes fields["heap_used_bytes"] = kibanaStatus.Metrics.Process.Mem.HeapUsedInBytes - } - acc.AddFields("kibana", fields, tags) return nil diff --git a/plugins/inputs/kubernetes/kubernetes.go b/plugins/inputs/kubernetes/kubernetes.go index 7845417e0..2516d084c 100644 --- a/plugins/inputs/kubernetes/kubernetes.go +++ b/plugins/inputs/kubernetes/kubernetes.go @@ -89,7 +89,6 @@ func (k *Kubernetes) Description() string { } func (k *Kubernetes) Init() error { - // If neither are provided, use the default service account. if k.BearerToken == "" && k.BearerTokenString == "" { k.BearerToken = defaultServiceAccountPath diff --git a/plugins/inputs/kubernetes/kubernetes_test.go b/plugins/inputs/kubernetes/kubernetes_test.go index faf40be3e..eb6d28552 100644 --- a/plugins/inputs/kubernetes/kubernetes_test.go +++ b/plugins/inputs/kubernetes/kubernetes_test.go @@ -21,7 +21,6 @@ func TestKubernetesStats(t *testing.T) { w.WriteHeader(http.StatusOK) fmt.Fprintln(w, responsePods) } - })) defer ts.Close() @@ -155,7 +154,6 @@ func TestKubernetesStats(t *testing.T) { "pod_name": "foopod", } acc.AssertContainsTaggedFields(t, "kubernetes_pod_network", fields, tags) - } var responsePods = ` diff --git a/plugins/inputs/lanz/lanz.go b/plugins/inputs/lanz/lanz.go index b1adcd6e7..6a833175f 100644 --- a/plugins/inputs/lanz/lanz.go +++ b/plugins/inputs/lanz/lanz.go @@ -48,7 +48,6 @@ func (l *Lanz) Gather(acc telegraf.Accumulator) error { } func (l *Lanz) Start(acc telegraf.Accumulator) error { - if len(l.Servers) == 0 { l.Servers = append(l.Servers, "tcp://127.0.0.1:50001") } diff --git a/plugins/inputs/lanz/lanz_test.go b/plugins/inputs/lanz/lanz_test.go index 26e1f5292..684bfc890 100644 --- a/plugins/inputs/lanz/lanz_test.go +++ b/plugins/inputs/lanz/lanz_test.go @@ -51,7 +51,6 @@ var testProtoBufGlobalBufferUsageRecord = &pb.LanzRecord{ } func TestLanzGeneratesMetrics(t *testing.T) { - var acc testutil.Accumulator l := NewLanz() @@ -133,5 +132,4 @@ func TestLanzGeneratesMetrics(t *testing.T) { acc.AssertContainsFields(t, "lanz_global_buffer_usage_record", gburVals1) acc.AssertContainsTaggedFields(t, "lanz_global_buffer_usage_record", gburVals1, gburTags1) - } diff --git a/plugins/inputs/linux_sysctl_fs/linux_sysctl_fs.go b/plugins/inputs/linux_sysctl_fs/linux_sysctl_fs.go index adb111836..5aa75f075 100644 --- a/plugins/inputs/linux_sysctl_fs/linux_sysctl_fs.go +++ b/plugins/inputs/linux_sysctl_fs/linux_sysctl_fs.go @@ -91,7 +91,6 @@ func GetHostProc() string { } func init() { - inputs.Add("linux_sysctl_fs", func() telegraf.Input { return &SysctlFS{ path: path.Join(GetHostProc(), "/sys/fs"), diff --git a/plugins/inputs/logparser/logparser.go b/plugins/inputs/logparser/logparser.go index 4fbd2e90d..fc38b467e 100644 --- a/plugins/inputs/logparser/logparser.go +++ b/plugins/inputs/logparser/logparser.go @@ -271,7 +271,6 @@ func (l *LogParserPlugin) receiver(tailer *tail.Tail) { var line *tail.Line for line = range tailer.Lines { - if line.Err != nil { l.Log.Errorf("Error tailing file %s, Error: %s", tailer.Filename, line.Err) @@ -321,7 +320,6 @@ func (l *LogParserPlugin) parser() { } else { l.Log.Errorf("Error parsing log line: %s", err.Error()) } - } } diff --git a/plugins/inputs/logstash/logstash.go b/plugins/inputs/logstash/logstash.go index e9218278f..92b392d67 100644 --- a/plugins/inputs/logstash/logstash.go +++ b/plugins/inputs/logstash/logstash.go @@ -270,8 +270,8 @@ func (logstash *Logstash) gatherPluginsStats( plugins []Plugin, pluginType string, tags map[string]string, - accumulator telegraf.Accumulator) error { - + accumulator telegraf.Accumulator, +) error { for _, plugin := range plugins { pluginTags := map[string]string{ "plugin_name": plugin.Name, @@ -295,9 +295,8 @@ func (logstash *Logstash) gatherPluginsStats( func (logstash *Logstash) gatherQueueStats( queue *PipelineQueue, tags map[string]string, - accumulator telegraf.Accumulator) error { - - var err error + accumulator telegraf.Accumulator, +) error { queueTags := map[string]string{ "queue_type": queue.Type, } @@ -311,7 +310,7 @@ func (logstash *Logstash) gatherQueueStats( if queue.Type != "memory" { flattener := jsonParser.JSONFlattener{} - err = flattener.FlattenJSON("", queue.Capacity) + err := flattener.FlattenJSON("", queue.Capacity) if err != nil { return err } diff --git a/plugins/inputs/logstash/logstash_test.go b/plugins/inputs/logstash/logstash_test.go index e849fa57d..b0d020b48 100644 --- a/plugins/inputs/logstash/logstash_test.go +++ b/plugins/inputs/logstash/logstash_test.go @@ -549,7 +549,6 @@ func Test_Logstash6GatherPipelinesStats(test *testing.T) { "queue_type": string("persisted"), }, ) - } func Test_Logstash5GatherJVMStats(test *testing.T) { @@ -618,7 +617,6 @@ func Test_Logstash5GatherJVMStats(test *testing.T) { "node_version": string("5.3.0"), }, ) - } func Test_Logstash6GatherJVMStats(test *testing.T) { @@ -687,5 +685,4 @@ func Test_Logstash6GatherJVMStats(test *testing.T) { "node_version": string("6.4.2"), }, ) - } diff --git a/plugins/inputs/lustre2/lustre2_test.go b/plugins/inputs/lustre2/lustre2_test.go index 9614eb059..e89c33b5a 100644 --- a/plugins/inputs/lustre2/lustre2_test.go +++ b/plugins/inputs/lustre2/lustre2_test.go @@ -133,7 +133,6 @@ const mdtJobStatsContents = `job_stats: ` func TestLustre2GeneratesMetrics(t *testing.T) { - tempdir := os.TempDir() + "/telegraf/proc/fs/lustre/" ostName := "OST0001" @@ -206,7 +205,6 @@ func TestLustre2GeneratesMetrics(t *testing.T) { } func TestLustre2GeneratesJobstatsMetrics(t *testing.T) { - tempdir := os.TempDir() + "/telegraf/proc/fs/lustre/" ostName := "OST0001" jobNames := []string{"cluster-testjob1", "testjob2"} diff --git a/plugins/inputs/mailchimp/mailchimp_test.go b/plugins/inputs/mailchimp/mailchimp_test.go index ba711bf74..c35a70660 100644 --- a/plugins/inputs/mailchimp/mailchimp_test.go +++ b/plugins/inputs/mailchimp/mailchimp_test.go @@ -137,7 +137,6 @@ func TestMailChimpGatherReport(t *testing.T) { "industry_type": "Social Networks and Online Communities", } acc.AssertContainsTaggedFields(t, "mailchimp", fields, tags) - } func TestMailChimpGatherError(t *testing.T) { diff --git a/plugins/inputs/marklogic/marklogic.go b/plugins/inputs/marklogic/marklogic.go index b79908caa..d2ef139bf 100644 --- a/plugins/inputs/marklogic/marklogic.go +++ b/plugins/inputs/marklogic/marklogic.go @@ -108,7 +108,6 @@ var sampleConfig = ` // Init parse all source URLs and place on the Marklogic struct func (c *Marklogic) Init() error { - if len(c.URL) == 0 { c.URL = "http://localhost:8002/" } diff --git a/plugins/inputs/marklogic/marklogic_test.go b/plugins/inputs/marklogic/marklogic_test.go index 34e4bbd6b..e6057f6e0 100644 --- a/plugins/inputs/marklogic/marklogic_test.go +++ b/plugins/inputs/marklogic/marklogic_test.go @@ -76,7 +76,6 @@ func TestMarklogic(t *testing.T) { } acc.AssertContainsTaggedFields(t, "marklogic", expectFields, expectTags) - } var response = ` diff --git a/plugins/inputs/mesos/mesos_test.go b/plugins/inputs/mesos/mesos_test.go index cdc5eada1..f06052c07 100644 --- a/plugins/inputs/mesos/mesos_test.go +++ b/plugins/inputs/mesos/mesos_test.go @@ -278,7 +278,6 @@ func generateMetrics() { for _, k := range slaveMetricNames { slaveMetrics[k] = rand.Float64() } - // slaveTaskMetrics = map[string]interface{}{ // "executor_id": fmt.Sprintf("task_name.%s", randUUID()), // "executor_name": "Some task description", diff --git a/plugins/inputs/minecraft/client.go b/plugins/inputs/minecraft/client.go index 3f3f54c17..bb829f690 100644 --- a/plugins/inputs/minecraft/client.go +++ b/plugins/inputs/minecraft/client.go @@ -157,7 +157,6 @@ func parsePlayers(input string) ([]string, error) { continue } players = append(players, name) - } return players, nil } diff --git a/plugins/inputs/modbus/modbus.go b/plugins/inputs/modbus/modbus.go index dbd952b52..7345aef68 100644 --- a/plugins/inputs/modbus/modbus.go +++ b/plugins/inputs/modbus/modbus.go @@ -483,7 +483,6 @@ func (m *Modbus) getFields() error { register.Fields[i].value = convertDataType(register.Fields[i], valuesT) } - } } diff --git a/plugins/inputs/mongodb/mongostat.go b/plugins/inputs/mongodb/mongostat.go index ee96d5f8b..6210b782e 100644 --- a/plugins/inputs/mongodb/mongostat.go +++ b/plugins/inputs/mongodb/mongostat.go @@ -1131,8 +1131,7 @@ func NewStatLine(oldMongo, newMongo MongoStatus, key string, all bool, sampleSec returnVal.NodeType = "ARB" } else { returnVal.NodeType = "UNK" - } - // END code modification + } // END code modification } else if returnVal.IsMongos { returnVal.NodeType = "RTR" } diff --git a/plugins/inputs/mongodb/mongostat_test.go b/plugins/inputs/mongodb/mongostat_test.go index 5506602a9..9f6ef0489 100644 --- a/plugins/inputs/mongodb/mongostat_test.go +++ b/plugins/inputs/mongodb/mongostat_test.go @@ -9,7 +9,6 @@ import ( ) func TestLatencyStats(t *testing.T) { - sl := NewStatLine( MongoStatus{ ServerStatus: &ServerStatus{ @@ -65,7 +64,6 @@ func TestLatencyStats(t *testing.T) { } func TestLatencyStatsDiffZero(t *testing.T) { - sl := NewStatLine( MongoStatus{ ServerStatus: &ServerStatus{ @@ -135,7 +133,6 @@ func TestLatencyStatsDiffZero(t *testing.T) { } func TestLatencyStatsDiff(t *testing.T) { - sl := NewStatLine( MongoStatus{ ServerStatus: &ServerStatus{ diff --git a/plugins/inputs/monit/monit.go b/plugins/inputs/monit/monit.go index 606bf0d4c..a25efad58 100644 --- a/plugins/inputs/monit/monit.go +++ b/plugins/inputs/monit/monit.go @@ -229,7 +229,6 @@ func (m *Monit) Init() error { } func (m *Monit) Gather(acc telegraf.Accumulator) error { - req, err := http.NewRequest("GET", fmt.Sprintf("%s/_status?format=xml", m.Address), nil) if err != nil { return err @@ -245,7 +244,6 @@ func (m *Monit) Gather(acc telegraf.Accumulator) error { defer resp.Body.Close() if resp.StatusCode == 200 { - var status Status decoder := xml.NewDecoder(resp.Body) decoder.CharsetReader = charset.NewReaderLabel @@ -345,10 +343,7 @@ func (m *Monit) Gather(acc telegraf.Accumulator) error { } } } else { - return fmt.Errorf("received status code %d (%s), expected 200", - resp.StatusCode, - http.StatusText(resp.StatusCode)) - + return fmt.Errorf("received status code %d (%s), expected 200", resp.StatusCode, http.StatusText(resp.StatusCode)) } return nil } diff --git a/plugins/inputs/monit/monit_test.go b/plugins/inputs/monit/monit_test.go index d17db8d2a..1a2970f1e 100644 --- a/plugins/inputs/monit/monit_test.go +++ b/plugins/inputs/monit/monit_test.go @@ -555,7 +555,6 @@ func checkAuth(r *http.Request, username, password string) bool { } func TestAllowHosts(t *testing.T) { - r := &Monit{ Address: "http://127.0.0.1:2812", Username: "test", @@ -591,9 +590,7 @@ func TestConnection(t *testing.T) { } func TestInvalidUsernameOrPassword(t *testing.T) { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if !checkAuth(r, "testing", "testing") { http.Error(w, "Unauthorized.", 401) return @@ -625,9 +622,7 @@ func TestInvalidUsernameOrPassword(t *testing.T) { } func TestNoUsernameOrPasswordConfiguration(t *testing.T) { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if !checkAuth(r, "testing", "testing") { http.Error(w, "Unauthorized.", 401) return @@ -657,7 +652,6 @@ func TestNoUsernameOrPasswordConfiguration(t *testing.T) { } func TestInvalidXMLAndInvalidTypes(t *testing.T) { - tests := []struct { name string filename string diff --git a/plugins/inputs/mysql/mysql.go b/plugins/inputs/mysql/mysql.go index 8e09a357f..30b7b68f2 100644 --- a/plugins/inputs/mysql/mysql.go +++ b/plugins/inputs/mysql/mysql.go @@ -1439,7 +1439,6 @@ func (m *Mysql) gatherPerfSummaryPerAccountPerEvent(db *sql.DB, serv string, acc "sum_no_good_index_used": sumNoGoodIndexUsed, } acc.AddFields("mysql_perf_acc_event", sqlLWFields, sqlLWTags) - } return nil @@ -1662,8 +1661,8 @@ func (m *Mysql) gatherPerfFileEventsStatuses(db *sql.DB, serv string, acc telegr fields["file_events_seconds_total"] = sumTimerWrite / picoSeconds fields["file_events_bytes_totals"] = sumNumBytesWrite acc.AddFields("mysql_perf_schema", fields, writeTags) - } + return nil } diff --git a/plugins/inputs/neptune_apex/neptune_apex_test.go b/plugins/inputs/neptune_apex/neptune_apex_test.go index cefa5fad1..6cca64952 100644 --- a/plugins/inputs/neptune_apex/neptune_apex_test.go +++ b/plugins/inputs/neptune_apex/neptune_apex_test.go @@ -51,7 +51,6 @@ func TestGather(t *testing.T) { t.Errorf("Number of servers mismatch. got=%d, want=%d", len(acc.Errors), len(test.servers)) } - }) } } diff --git a/plugins/inputs/nfsclient/nfsclient.go b/plugins/inputs/nfsclient/nfsclient.go index 37fa64fef..e4005b576 100644 --- a/plugins/inputs/nfsclient/nfsclient.go +++ b/plugins/inputs/nfsclient/nfsclient.go @@ -239,7 +239,6 @@ func (n *NFSClient) parseStat(mountpoint string, export string, version string, acc.AddFields("nfs_ops", fields, tags) } } - } return nil @@ -304,7 +303,6 @@ func (n *NFSClient) processText(scanner *bufio.Scanner, acc telegraf.Accumulator } func (n *NFSClient) getMountStatsPath() string { - path := "/proc/self/mountstats" if os.Getenv("MOUNT_PROC") != "" { path = os.Getenv("MOUNT_PROC") @@ -314,7 +312,6 @@ func (n *NFSClient) getMountStatsPath() string { } func (n *NFSClient) Gather(acc telegraf.Accumulator) error { - file, err := os.Open(n.mountstatsPath) if err != nil { n.Log.Errorf("Failed opening the [%s] file: %s ", file, err) @@ -334,7 +331,6 @@ func (n *NFSClient) Gather(acc telegraf.Accumulator) error { } func (n *NFSClient) Init() error { - var nfs3Fields = []string{ "NULL", "GETATTR", diff --git a/plugins/inputs/nfsclient/nfsclient_test.go b/plugins/inputs/nfsclient/nfsclient_test.go index f4f008fbc..72813cc10 100644 --- a/plugins/inputs/nfsclient/nfsclient_test.go +++ b/plugins/inputs/nfsclient/nfsclient_test.go @@ -9,7 +9,6 @@ import ( ) func getMountStatsPath() string { - path := "./testdata/mountstats" if os.Getenv("MOUNT_PROC") != "" { path = os.Getenv("MOUNT_PROC") diff --git a/plugins/inputs/nginx_plus/nginx_plus.go b/plugins/inputs/nginx_plus/nginx_plus.go index 80811cc8d..d41c03c80 100644 --- a/plugins/inputs/nginx_plus/nginx_plus.go +++ b/plugins/inputs/nginx_plus/nginx_plus.go @@ -318,7 +318,6 @@ func (s *Status) gatherProcessesMetrics(tags map[string]string, acc telegraf.Acc }, tags, ) - } func (s *Status) gatherConnectionsMetrics(tags map[string]string, acc telegraf.Accumulator) { diff --git a/plugins/inputs/nginx_plus/nginx_plus_test.go b/plugins/inputs/nginx_plus/nginx_plus_test.go index d7531de97..caaea7dcb 100644 --- a/plugins/inputs/nginx_plus/nginx_plus_test.go +++ b/plugins/inputs/nginx_plus/nginx_plus_test.go @@ -409,5 +409,4 @@ func TestNginxPlusGeneratesMetrics(t *testing.T) { "upstream_address": "1.2.3.123:80", "id": "0", }) - } diff --git a/plugins/inputs/nginx_plus_api/nginx_plus_api_metrics_test.go b/plugins/inputs/nginx_plus_api/nginx_plus_api_metrics_test.go index be155f073..5e05e9f0d 100644 --- a/plugins/inputs/nginx_plus_api/nginx_plus_api_metrics_test.go +++ b/plugins/inputs/nginx_plus_api/nginx_plus_api_metrics_test.go @@ -1159,7 +1159,6 @@ func TestGatherStreamUpstreams(t *testing.T) { "upstream_address": "10.0.0.1:12348", "id": "1", }) - } func TestGatherStreamServerZonesMetrics(t *testing.T) { diff --git a/plugins/inputs/nginx_upstream_check/nginx_upstream_check.go b/plugins/inputs/nginx_upstream_check/nginx_upstream_check.go index 34aff538c..da2f7b08f 100644 --- a/plugins/inputs/nginx_upstream_check/nginx_upstream_check.go +++ b/plugins/inputs/nginx_upstream_check/nginx_upstream_check.go @@ -123,7 +123,6 @@ func (check *NginxUpstreamCheck) createHTTPClient() (*http.Client, error) { // gatherJSONData query the data source and parse the response JSON func (check *NginxUpstreamCheck) gatherJSONData(url string, value interface{}) error { - var method string if check.Method != "" { method = check.Method @@ -187,7 +186,6 @@ func (check *NginxUpstreamCheck) Gather(accumulator telegraf.Accumulator) error } return nil - } func (check *NginxUpstreamCheck) gatherStatusData(url string, accumulator telegraf.Accumulator) error { @@ -199,7 +197,6 @@ func (check *NginxUpstreamCheck) gatherStatusData(url string, accumulator telegr } for _, server := range checkData.Servers.Server { - tags := map[string]string{ "upstream": server.Upstream, "type": server.Type, diff --git a/plugins/inputs/nginx_upstream_check/nginx_upstream_check_test.go b/plugins/inputs/nginx_upstream_check/nginx_upstream_check_test.go index 1b70770d0..df6b08b09 100644 --- a/plugins/inputs/nginx_upstream_check/nginx_upstream_check_test.go +++ b/plugins/inputs/nginx_upstream_check/nginx_upstream_check_test.go @@ -116,7 +116,6 @@ func TestNginxUpstreamCheckRequest(test *testing.T) { require.Equal(test, request.Header.Get("X-Test"), "test-value") require.Equal(test, request.Header.Get("Authorization"), "Basic dXNlcjpwYXNzd29yZA==") require.Equal(test, request.Host, "status.local") - })) defer testServer.Close() diff --git a/plugins/inputs/nsd/nsd_test.go b/plugins/inputs/nsd/nsd_test.go index ee527f7b7..fbe66ca9e 100644 --- a/plugins/inputs/nsd/nsd_test.go +++ b/plugins/inputs/nsd/nsd_test.go @@ -35,7 +35,6 @@ func TestParseFullOutput(t *testing.T) { acc.AssertContainsFields(t, "nsd", parsedFullOutput) acc.AssertContainsFields(t, "nsd_servers", parsedFullOutputServerAsTag) - } var parsedFullOutputServerAsTag = map[string]interface{}{ diff --git a/plugins/inputs/nsq_consumer/nsq_consumer_test.go b/plugins/inputs/nsq_consumer/nsq_consumer_test.go index e07b125cc..bcc1fdf32 100644 --- a/plugins/inputs/nsq_consumer/nsq_consumer_test.go +++ b/plugins/inputs/nsq_consumer/nsq_consumer_test.go @@ -68,7 +68,6 @@ func TestReadsMetricsFromNSQ(t *testing.T) { } else { t.Errorf("No points found in accumulator, expected 1") } - } // Waits for the metric that was sent to the kafka broker to arrive at the kafka diff --git a/plugins/inputs/opcua/opcua_util.go b/plugins/inputs/opcua/opcua_util.go index c0eac2483..a115f8558 100644 --- a/plugins/inputs/opcua/opcua_util.go +++ b/plugins/inputs/opcua/opcua_util.go @@ -32,7 +32,6 @@ func newTempDir() (string, error) { } func generateCert(host string, rsaBits int, certFile, keyFile string, dur time.Duration) (string, string) { - dir, _ := newTempDir() if len(host) == 0 { @@ -310,7 +309,6 @@ func generateAuth(a string, cert []byte, un, pw string) (ua.UserTokenType, opcua log.Printf("unknown auth-mode, defaulting to Anonymous") authMode = ua.UserTokenTypeAnonymous authOption = opcua.AuthAnonymous() - } return authMode, authOption diff --git a/plugins/inputs/openntpd/openntpd.go b/plugins/inputs/openntpd/openntpd.go index e7723b480..c3fc3e92e 100644 --- a/plugins/inputs/openntpd/openntpd.go +++ b/plugins/inputs/openntpd/openntpd.go @@ -156,16 +156,13 @@ func (n *Openntpd) Gather(acc telegraf.Accumulator) error { } if key == "next" || key == "poll" { - m, err := strconv.ParseInt(strings.TrimSuffix(fields[index], "s"), 10, 64) if err != nil { acc.AddError(fmt.Errorf("integer value expected, got: %s", fields[index])) continue } mFields[key] = m - } else { - m, err := strconv.ParseInt(fields[index], 10, 64) if err != nil { acc.AddError(fmt.Errorf("integer value expected, got: %s", fields[index])) @@ -185,23 +182,19 @@ func (n *Openntpd) Gather(acc telegraf.Accumulator) error { } if key == "offset" || key == "delay" || key == "jitter" { - m, err := strconv.ParseFloat(strings.TrimSuffix(fields[index], "ms"), 64) if err != nil { acc.AddError(fmt.Errorf("float value expected, got: %s", fields[index])) continue } mFields[key] = m - } else { - m, err := strconv.ParseFloat(fields[index], 64) if err != nil { acc.AddError(fmt.Errorf("float value expected, got: %s", fields[index])) continue } mFields[key] = m - } } acc.AddFields("openntpd", mFields, tags) diff --git a/plugins/inputs/opensmtpd/opensmtpd.go b/plugins/inputs/opensmtpd/opensmtpd.go index 11660a840..cea266cc8 100644 --- a/plugins/inputs/opensmtpd/opensmtpd.go +++ b/plugins/inputs/opensmtpd/opensmtpd.go @@ -92,7 +92,6 @@ func (s *Opensmtpd) Gather(acc telegraf.Accumulator) error { fields := make(map[string]interface{}) scanner := bufio.NewScanner(out) for scanner.Scan() { - cols := strings.Split(scanner.Text(), "=") // Check split correctness diff --git a/plugins/inputs/openweathermap/openweathermap.go b/plugins/inputs/openweathermap/openweathermap.go index bda43438d..688f97782 100644 --- a/plugins/inputs/openweathermap/openweathermap.go +++ b/plugins/inputs/openweathermap/openweathermap.go @@ -124,7 +124,6 @@ func (n *OpenWeatherMap) Gather(acc telegraf.Accumulator) error { gatherWeather(acc, status) }() } - } } diff --git a/plugins/inputs/pf/pf.go b/plugins/inputs/pf/pf.go index 035c44fbe..429169d54 100644 --- a/plugins/inputs/pf/pf.go +++ b/plugins/inputs/pf/pf.go @@ -164,7 +164,6 @@ func parseCounterTable(lines []string, fields map[string]interface{}) error { } func storeFieldValues(lines []string, regex *regexp.Regexp, fields map[string]interface{}, entryTable []*Entry) error { - for _, v := range lines { entries := regex.FindStringSubmatch(v) if entries != nil { diff --git a/plugins/inputs/phpfpm/phpfpm_test.go b/plugins/inputs/phpfpm/phpfpm_test.go index 645782289..b077f7955 100644 --- a/plugins/inputs/phpfpm/phpfpm_test.go +++ b/plugins/inputs/phpfpm/phpfpm_test.go @@ -328,7 +328,6 @@ func TestPhpFpmGeneratesMetrics_Throw_Error_When_Socket_Path_Is_Invalid(t *testi err = acc.GatherError(r.Gather) require.Error(t, err) assert.Equal(t, `socket doesn't exist "/tmp/invalid.sock"`, err.Error()) - } const outputSample = ` diff --git a/plugins/inputs/ping/ping.go b/plugins/inputs/ping/ping.go index 947054845..6249677ea 100644 --- a/plugins/inputs/ping/ping.go +++ b/plugins/inputs/ping/ping.go @@ -202,7 +202,6 @@ func (p *Ping) nativePing(destination string) (*pingStats, error) { } func (p *Ping) pingToURLNative(destination string, acc telegraf.Accumulator) { - tags := map[string]string{"url": destination} fields := map[string]interface{}{} diff --git a/plugins/inputs/ping/ping_test.go b/plugins/inputs/ping/ping_test.go index daebeb1f5..e42f4b97a 100644 --- a/plugins/inputs/ping/ping_test.go +++ b/plugins/inputs/ping/ping_test.go @@ -487,7 +487,6 @@ func TestPingGatherNative(t *testing.T) { assert.True(t, acc.HasField("ping", "maximum_response_ms")) assert.True(t, acc.HasField("ping", "standard_deviation_ms")) } - } func TestNoPacketsSent(t *testing.T) { diff --git a/plugins/inputs/powerdns/powerdns_test.go b/plugins/inputs/powerdns/powerdns_test.go index 0fe3e3105..19be4a7df 100644 --- a/plugins/inputs/powerdns/powerdns_test.go +++ b/plugins/inputs/powerdns/powerdns_test.go @@ -51,7 +51,6 @@ var intOverflowMetrics = "corrupt-packets=18446744073709550195,deferred-cache-in "signature-cache-size=0,sys-msec=2889,uptime=86317,user-msec=2167," func (s statServer) serverSocket(l net.Listener) { - for { conn, err := l.Accept() if err != nil { diff --git a/plugins/inputs/procstat/native_finder.go b/plugins/inputs/procstat/native_finder.go index 799f01838..d5d8b8b36 100644 --- a/plugins/inputs/procstat/native_finder.go +++ b/plugins/inputs/procstat/native_finder.go @@ -54,7 +54,6 @@ func (pg *NativeFinder) PidFile(path string) ([]PID, error) { } pids = append(pids, PID(pid)) return pids, nil - } //FullPattern matches on the command line when the process was executed diff --git a/plugins/inputs/procstat/procstat.go b/plugins/inputs/procstat/procstat.go index a27ea2c93..62de739b2 100644 --- a/plugins/inputs/procstat/procstat.go +++ b/plugins/inputs/procstat/procstat.go @@ -111,7 +111,6 @@ func (p *Procstat) Gather(acc telegraf.Accumulator) error { p.PidFinder = "pgrep" p.createPIDFinder = defaultPIDFinder } - } if p.createProcess == nil { p.createProcess = defaultProcess diff --git a/plugins/inputs/prometheus/kubernetes.go b/plugins/inputs/prometheus/kubernetes.go index 2ed08dd3f..bb599bf38 100644 --- a/plugins/inputs/prometheus/kubernetes.go +++ b/plugins/inputs/prometheus/kubernetes.go @@ -107,7 +107,6 @@ func (p *Prometheus) start(ctx context.Context) error { // pod, causing errors in the logs. This is only true if the pod going offline is not // directed to do so by K8s. func (p *Prometheus) watch(ctx context.Context, client *k8s.Client) error { - selectors := podSelector(p) pod := &corev1.Pod{} @@ -189,7 +188,6 @@ func (p *Prometheus) cAdvisor(ctx context.Context, client *k8s.Client) error { } func updateCadvisorPodList(ctx context.Context, p *Prometheus, client *k8s.Client, req *http.Request) error { - resp, err := client.Client.Do(req) if err != nil { return fmt.Errorf("Error when making request for pod list: %w", err) @@ -224,7 +222,6 @@ func updateCadvisorPodList(ctx context.Context, p *Prometheus, client *k8s.Clien podHasMatchingFieldSelector(pod, p.podFieldSelector) { registerPod(pod, p) } - } p.lock.Unlock() @@ -316,7 +313,6 @@ func podSelector(p *Prometheus) []k8s.Option { } return options - } func registerPod(pod *corev1.Pod, p *Prometheus) { diff --git a/plugins/inputs/prometheus/kubernetes_test.go b/plugins/inputs/prometheus/kubernetes_test.go index 5a6860191..7e6e62409 100644 --- a/plugins/inputs/prometheus/kubernetes_test.go +++ b/plugins/inputs/prometheus/kubernetes_test.go @@ -100,7 +100,6 @@ func TestDeletePods(t *testing.T) { } func TestPodSelector(t *testing.T) { - cases := []struct { expected []k8s.Option labelselector string diff --git a/plugins/inputs/prometheus/parser.go b/plugins/inputs/prometheus/parser.go index c4b3cb340..d62602dc1 100644 --- a/plugins/inputs/prometheus/parser.go +++ b/plugins/inputs/prometheus/parser.go @@ -69,7 +69,6 @@ func Parse(buf []byte, header http.Header) ([]telegraf.Metric, error) { fields = makeBuckets(m) fields["count"] = float64(m.GetHistogram().GetSampleCount()) fields["sum"] = float64(m.GetHistogram().GetSampleSum()) - } else { // standard metric fields = getNameAndValue(m) diff --git a/plugins/inputs/prometheus/parser_test.go b/plugins/inputs/prometheus/parser_test.go index 7b2bfeca2..a80cdbd5a 100644 --- a/plugins/inputs/prometheus/parser_test.go +++ b/plugins/inputs/prometheus/parser_test.go @@ -163,5 +163,4 @@ func TestParseValidPrometheus(t *testing.T) { assert.Equal(t, map[string]string{"verb": "POST", "resource": "bindings"}, metrics[0].Tags()) - } diff --git a/plugins/inputs/prometheus/prometheus.go b/plugins/inputs/prometheus/prometheus.go index f94fcf104..cdf3bc84b 100644 --- a/plugins/inputs/prometheus/prometheus.go +++ b/plugins/inputs/prometheus/prometheus.go @@ -163,7 +163,6 @@ func (p *Prometheus) Init() error { // Config proccessing for node scrape scope for monitor_kubernetes_pods p.isNodeScrapeScope = strings.EqualFold(p.PodScrapeScope, "node") if p.isNodeScrapeScope { - // Need node IP to make cAdvisor call for pod list. Check if set in config and valid IP address if p.NodeIP == "" || net.ParseIP(p.NodeIP) == nil { p.Log.Infof("The config node_ip is empty or invalid. Using NODE_IP env var as default.") diff --git a/plugins/inputs/prometheus/prometheus_test.go b/plugins/inputs/prometheus/prometheus_test.go index a727af49c..230934d0e 100644 --- a/plugins/inputs/prometheus/prometheus_test.go +++ b/plugins/inputs/prometheus/prometheus_test.go @@ -149,7 +149,6 @@ func TestPrometheusGeneratesSummaryMetricsV2(t *testing.T) { assert.True(t, acc.HasFloatField("prometheus", "go_gc_duration_seconds_sum")) assert.True(t, acc.HasFloatField("prometheus", "go_gc_duration_seconds_count")) assert.True(t, acc.TagValue("prometheus", "url") == ts.URL+"/metrics") - } func TestSummaryMayContainNaN(t *testing.T) { diff --git a/plugins/inputs/puppetagent/puppetagent.go b/plugins/inputs/puppetagent/puppetagent.go index 1d0e30aa8..741de4a0d 100644 --- a/plugins/inputs/puppetagent/puppetagent.go +++ b/plugins/inputs/puppetagent/puppetagent.go @@ -84,7 +84,6 @@ func (pa *PuppetAgent) Description() string { // Gather reads stats from all configured servers accumulates stats func (pa *PuppetAgent) Gather(acc telegraf.Accumulator) error { - if len(pa.Location) == 0 { pa.Location = "/var/lib/puppet/state/last_run_summary.yaml" } diff --git a/plugins/inputs/raindrops/raindrops.go b/plugins/inputs/raindrops/raindrops.go index fbf9f929f..5973390e9 100644 --- a/plugins/inputs/raindrops/raindrops.go +++ b/plugins/inputs/raindrops/raindrops.go @@ -147,7 +147,6 @@ func (r *Raindrops) gatherURL(addr *url.URL, acc telegraf.Accumulator) error { "ip": listener[0], "port": listener[1], } - } else { tags = map[string]string{ "socket": listenName, diff --git a/plugins/inputs/redfish/redfish_test.go b/plugins/inputs/redfish/redfish_test.go index c31f65013..568db0009 100644 --- a/plugins/inputs/redfish/redfish_test.go +++ b/plugins/inputs/redfish/redfish_test.go @@ -15,9 +15,7 @@ import ( ) func TestDellApis(t *testing.T) { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if !checkAuth(r, "test", "test") { http.Error(w, "Unauthorized.", 401) return @@ -502,9 +500,7 @@ func TestDellApis(t *testing.T) { } func TestHPApis(t *testing.T) { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if !checkAuth(r, "test", "test") { http.Error(w, "Unauthorized.", 401) return @@ -672,9 +668,7 @@ func checkAuth(r *http.Request, username, password string) bool { } func TestInvalidUsernameorPassword(t *testing.T) { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if !checkAuth(r, "testing", "testing") { http.Error(w, "Unauthorized.", 401) return @@ -704,9 +698,7 @@ func TestInvalidUsernameorPassword(t *testing.T) { require.EqualError(t, err, "received status code 401 (Unauthorized) for address http://"+u.Host+", expected 200") } func TestNoUsernameorPasswordConfiguration(t *testing.T) { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if !checkAuth(r, "testing", "testing") { http.Error(w, "Unauthorized.", 401) return @@ -732,7 +724,6 @@ func TestNoUsernameorPasswordConfiguration(t *testing.T) { } func TestInvalidDellJSON(t *testing.T) { - tests := []struct { name string thermalfilename string @@ -771,7 +762,6 @@ func TestInvalidDellJSON(t *testing.T) { } for _, tt := range tests { ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if !checkAuth(r, "test", "test") { http.Error(w, "Unauthorized.", 401) return @@ -809,7 +799,6 @@ func TestInvalidDellJSON(t *testing.T) { } func TestInvalidHPJSON(t *testing.T) { - tests := []struct { name string thermalfilename string @@ -842,7 +831,6 @@ func TestInvalidHPJSON(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if !checkAuth(r, "test", "test") { http.Error(w, "Unauthorized.", 401) return diff --git a/plugins/inputs/riemann_listener/riemann_listener.go b/plugins/inputs/riemann_listener/riemann_listener.go index 662e74287..de872e948 100644 --- a/plugins/inputs/riemann_listener/riemann_listener.go +++ b/plugins/inputs/riemann_listener/riemann_listener.go @@ -223,9 +223,7 @@ func (rsl *riemannListener) read(conn net.Conn) { rsl.AddMetric(singleMetric) } riemannReturnResponse(conn) - } - } func riemannReturnResponse(conn net.Conn) { @@ -358,7 +356,6 @@ func (rsl *RiemannSocketListener) Start(acc telegraf.Accumulator) error { go func() { defer rsl.wg.Done() rsl.listen(ctx) - }() default: return fmt.Errorf("unknown protocol '%s' in '%s'", protocol, rsl.ServiceAddress) @@ -380,7 +377,6 @@ func processOsSignals(cancelFunc context.CancelFunc) { return } } - } func (rsl *RiemannSocketListener) Stop() { diff --git a/plugins/inputs/riemann_listener/riemann_listener_test.go b/plugins/inputs/riemann_listener/riemann_listener_test.go index f1ce824c6..6948354a8 100644 --- a/plugins/inputs/riemann_listener/riemann_listener_test.go +++ b/plugins/inputs/riemann_listener/riemann_listener_test.go @@ -40,7 +40,6 @@ func testStats(t *testing.T, sl *RiemannSocketListener) { Service: "hello", }) assert.Equal(t, result.GetOk(), true) - } func testMissingService(t *testing.T, sl *RiemannSocketListener) { c := riemanngo.NewTCPClient("127.0.0.1:5555", 5*time.Second) @@ -51,5 +50,4 @@ func testMissingService(t *testing.T, sl *RiemannSocketListener) { defer c.Close() result, err := riemanngo.SendEvent(c, &riemanngo.Event{}) assert.Equal(t, result.GetOk(), false) - } diff --git a/plugins/inputs/sensors/sensors.go b/plugins/inputs/sensors/sensors.go index 1df88466b..01fd2a45a 100644 --- a/plugins/inputs/sensors/sensors.go +++ b/plugins/inputs/sensors/sensors.go @@ -41,7 +41,6 @@ func (*Sensors) SampleConfig() string { ## Timeout is the maximum amount of time that the sensors command can run. # timeout = "5s" ` - } func (s *Sensors) Gather(acc telegraf.Accumulator) error { diff --git a/plugins/inputs/sensors/sensors_test.go b/plugins/inputs/sensors/sensors_test.go index 2a24fa6f9..75fd3e468 100644 --- a/plugins/inputs/sensors/sensors_test.go +++ b/plugins/inputs/sensors/sensors_test.go @@ -377,7 +377,6 @@ Vcore Voltage: } else { fmt.Fprint(os.Stdout, "command not found") os.Exit(1) - } os.Exit(0) } diff --git a/plugins/inputs/sflow/sflow.go b/plugins/inputs/sflow/sflow.go index 2e3fbc0cf..f4283cabe 100644 --- a/plugins/inputs/sflow/sflow.go +++ b/plugins/inputs/sflow/sflow.go @@ -131,7 +131,6 @@ func (s *SFlow) read(acc telegraf.Accumulator, conn net.PacketConn) { } func (s *SFlow) process(acc telegraf.Accumulator, buf []byte) { - if err := s.decoder.Decode(bytes.NewBuffer(buf)); err != nil { acc.AddError(fmt.Errorf("unable to parse incoming packet: %s", err)) } diff --git a/plugins/inputs/snmp/snmp.go b/plugins/inputs/snmp/snmp.go index df23eeeb7..35d00629a 100644 --- a/plugins/inputs/snmp/snmp.go +++ b/plugins/inputs/snmp/snmp.go @@ -674,7 +674,6 @@ func fieldConvert(conv string, v interface{}) (interface{}, error) { split := strings.Split(conv, ":") if split[0] == "hextoint" && len(split) == 3 { - endian := split[1] bit := split[2] diff --git a/plugins/inputs/snmp_trap/snmp_trap.go b/plugins/inputs/snmp_trap/snmp_trap.go index e14d129e8..a887d5389 100644 --- a/plugins/inputs/snmp_trap/snmp_trap.go +++ b/plugins/inputs/snmp_trap/snmp_trap.go @@ -206,7 +206,6 @@ func (s *SnmpTrap) Start(acc telegraf.Accumulator) error { AuthenticationPassphrase: s.AuthPassword, AuthenticationProtocol: authenticationProtocol, } - } // wrap the handler, used in unit tests diff --git a/plugins/inputs/snmp_trap/snmp_trap_test.go b/plugins/inputs/snmp_trap/snmp_trap_test.go index b5f8da27a..a8c3d01c7 100644 --- a/plugins/inputs/snmp_trap/snmp_trap_test.go +++ b/plugins/inputs/snmp_trap/snmp_trap_test.go @@ -1318,5 +1318,4 @@ func TestReceiveTrap(t *testing.T) { testutil.SortMetrics()) }) } - } diff --git a/plugins/inputs/solr/solr.go b/plugins/inputs/solr/solr.go index 78652c6aa..9a850bbdb 100644 --- a/plugins/inputs/solr/solr.go +++ b/plugins/inputs/solr/solr.go @@ -285,7 +285,6 @@ func addQueryHandlerMetricsToAcc(acc telegraf.Accumulator, core string, mBeansDa "handler": name}, time, ) - } return nil } diff --git a/plugins/inputs/solr/solr_test.go b/plugins/inputs/solr/solr_test.go index 270816909..f4451ccc4 100644 --- a/plugins/inputs/solr/solr_test.go +++ b/plugins/inputs/solr/solr_test.go @@ -104,7 +104,6 @@ func TestNoCoreDataHandling(t *testing.T) { acc.AssertDoesNotContainMeasurement(t, "solr_queryhandler") acc.AssertDoesNotContainMeasurement(t, "solr_updatehandler") acc.AssertDoesNotContainMeasurement(t, "solr_handler") - } func createMockServer() *httptest.Server { diff --git a/plugins/inputs/sqlserver/sqlserver_test.go b/plugins/inputs/sqlserver/sqlserver_test.go index b271c08d6..f462ebbf8 100644 --- a/plugins/inputs/sqlserver/sqlserver_test.go +++ b/plugins/inputs/sqlserver/sqlserver_test.go @@ -43,7 +43,6 @@ func TestSqlServer_QueriesInclusionExclusion(t *testing.T) { } func TestSqlServer_ParseMetrics(t *testing.T) { - var acc testutil.Accumulator queries := make(MapQuery) @@ -63,7 +62,6 @@ func TestSqlServer_ParseMetrics(t *testing.T) { var fields = make(map[string]interface{}) for _, query := range queries { - mock = strings.Split(query.Script, "\n") idx := 0 @@ -78,7 +76,6 @@ func TestSqlServer_ParseMetrics(t *testing.T) { tags[headers[2]] = row[2] // tag 'type' if query.ResultByRow { - // set value by converting to float64 value, err := strconv.ParseFloat(row[3], 64) // require @@ -90,11 +87,9 @@ func TestSqlServer_ParseMetrics(t *testing.T) { tags, time.Now()) // assert acc.AssertContainsTaggedFields(t, measurement, map[string]interface{}{"value": value}, tags) - } else { // set fields for i := 3; i < len(row); i++ { - // set value by converting to float64 value, err := strconv.ParseFloat(row[i], 64) // require @@ -232,7 +227,6 @@ func TestSqlServer_HealthMetric(t *testing.T) { } func TestSqlServer_MultipleInit(t *testing.T) { - s := &SQLServer{} s2 := &SQLServer{ ExcludeQuery: []string{"DatabaseSize"}, diff --git a/plugins/inputs/stackdriver/stackdriver_test.go b/plugins/inputs/stackdriver/stackdriver_test.go index 8010ad481..ee1f7ac9b 100644 --- a/plugins/inputs/stackdriver/stackdriver_test.go +++ b/plugins/inputs/stackdriver/stackdriver_test.go @@ -803,7 +803,6 @@ func TestGatherAlign(t *testing.T) { } testutil.RequireMetricsEqual(t, tt.expected, actual) - }) } } diff --git a/plugins/inputs/suricata/suricata_test.go b/plugins/inputs/suricata/suricata_test.go index 3308f28b5..7259e658d 100644 --- a/plugins/inputs/suricata/suricata_test.go +++ b/plugins/inputs/suricata/suricata_test.go @@ -202,7 +202,6 @@ func TestSuricataTooLongLine(t *testing.T) { c.Close() acc.WaitError(1) - } func TestSuricataEmptyJSON(t *testing.T) { @@ -224,7 +223,6 @@ func TestSuricataEmptyJSON(t *testing.T) { c, err := net.Dial("unix", tmpfn) if err != nil { log.Println(err) - } c.Write([]byte("\n")) c.Close() diff --git a/plugins/inputs/sysstat/sysstat.go b/plugins/inputs/sysstat/sysstat.go index 9f530024b..528f4ec43 100644 --- a/plugins/inputs/sysstat/sysstat.go +++ b/plugins/inputs/sysstat/sysstat.go @@ -273,7 +273,6 @@ func (s *Sysstat) parse(acc telegraf.Accumulator, option string, ts time.Time) e tags[k] = v } } - } } @@ -299,7 +298,6 @@ func (s *Sysstat) parse(acc telegraf.Accumulator, option string, ts time.Time) e } acc.AddFields(measurement, fields, tags, ts) } - } if s.Group { for _, v := range m { diff --git a/plugins/inputs/temp/temp_test.go b/plugins/inputs/temp/temp_test.go index 080ff66ac..9ced8ac14 100644 --- a/plugins/inputs/temp/temp_test.go +++ b/plugins/inputs/temp/temp_test.go @@ -34,5 +34,4 @@ func TestTemperature(t *testing.T) { "sensor": "coretemp_sensor1_crit", } acc.AssertContainsTaggedFields(t, "temp", expectedFields, expectedTags) - } diff --git a/plugins/inputs/trig/trig_test.go b/plugins/inputs/trig/trig_test.go index 1471edbea..27bee81dd 100644 --- a/plugins/inputs/trig/trig_test.go +++ b/plugins/inputs/trig/trig_test.go @@ -13,7 +13,6 @@ func TestTrig(t *testing.T) { } for i := 0.0; i < 10.0; i++ { - var acc testutil.Accumulator sine := math.Sin((i*math.Pi)/5.0) * s.Amplitude diff --git a/plugins/inputs/unbound/unbound.go b/plugins/inputs/unbound/unbound.go index bb4ecde58..9b04bbf27 100644 --- a/plugins/inputs/unbound/unbound.go +++ b/plugins/inputs/unbound/unbound.go @@ -125,7 +125,6 @@ func unboundRunner(cmdName string, Timeout internal.Duration, UseSudo bool, Serv // // All the dots in stat name will replaced by underscores. Histogram statistics will not be collected. func (s *Unbound) Gather(acc telegraf.Accumulator) error { - // Always exclude histogram statistics statExcluded := []string{"histogram.*"} filterExcluded, err := filter.Compile(statExcluded) @@ -144,7 +143,6 @@ func (s *Unbound) Gather(acc telegraf.Accumulator) error { scanner := bufio.NewScanner(out) for scanner.Scan() { - cols := strings.Split(scanner.Text(), "=") // Check split correctness @@ -191,7 +189,6 @@ func (s *Unbound) Gather(acc telegraf.Accumulator) error { field := strings.Replace(stat, ".", "_", -1) fields[field] = fieldValue } - } acc.AddFields("unbound", fields, nil) diff --git a/plugins/inputs/uwsgi/uwsgi.go b/plugins/inputs/uwsgi/uwsgi.go index b13a7b3e6..81dd3c350 100644 --- a/plugins/inputs/uwsgi/uwsgi.go +++ b/plugins/inputs/uwsgi/uwsgi.go @@ -210,7 +210,6 @@ func (u *Uwsgi) gatherCores(acc telegraf.Accumulator, s *StatsServer) { } acc.AddFields("uwsgi_cores", fields, tags) } - } } diff --git a/plugins/inputs/vsphere/endpoint.go b/plugins/inputs/vsphere/endpoint.go index 7da90949e..0eb1b0ab9 100644 --- a/plugins/inputs/vsphere/endpoint.go +++ b/plugins/inputs/vsphere/endpoint.go @@ -827,7 +827,6 @@ func (e *Endpoint) Close() { // Collect runs a round of data collections as specified in the configuration. func (e *Endpoint) Collect(ctx context.Context, acc telegraf.Accumulator) error { - // If we never managed to do a discovery, collection will be a no-op. Therefore, // we need to check that a connection is available, or the collection will // silently fail. @@ -896,7 +895,6 @@ func (e *Endpoint) chunkify(ctx context.Context, res *resourceKind, now time.Tim for _, object := range res.objects { timeBuckets := make(map[int64]*types.PerfQuerySpec, 0) for metricIdx, metric := range res.metrics { - // Determine time of last successful collection metricName := e.getMetricNameForID(metric.CounterId) if metricName == "" { diff --git a/plugins/inputs/vsphere/vsphere.go b/plugins/inputs/vsphere/vsphere.go index 600780a57..300261358 100644 --- a/plugins/inputs/vsphere/vsphere.go +++ b/plugins/inputs/vsphere/vsphere.go @@ -315,7 +315,6 @@ func (v *VSphere) Gather(acc telegraf.Accumulator) error { defer wg.Done() err := endpoint.Collect(context.Background(), acc) if err == context.Canceled { - // No need to signal errors if we were merely canceled. err = nil } diff --git a/plugins/inputs/vsphere/vsphere_test.go b/plugins/inputs/vsphere/vsphere_test.go index 20e26d293..60e7e1c8d 100644 --- a/plugins/inputs/vsphere/vsphere_test.go +++ b/plugins/inputs/vsphere/vsphere_test.go @@ -471,7 +471,6 @@ func testCollection(t *testing.T, excludeClusters bool) { v.Username = username v.Password = password } else { - // Don't run test on 32-bit machines due to bug in simulator. // https://github.com/vmware/govmomi/issues/1330 var i int diff --git a/plugins/inputs/webhooks/papertrail/papertrail_webhooks.go b/plugins/inputs/webhooks/papertrail/papertrail_webhooks.go index 42453c130..7f11e31e7 100644 --- a/plugins/inputs/webhooks/papertrail/papertrail_webhooks.go +++ b/plugins/inputs/webhooks/papertrail/papertrail_webhooks.go @@ -41,7 +41,6 @@ func (pt *PapertrailWebhook) eventHandler(w http.ResponseWriter, r *http.Request } if payload.Events != nil { - // Handle event-based payload for _, e := range payload.Events { // Warning: Duplicate event timestamps will overwrite each other @@ -54,9 +53,7 @@ func (pt *PapertrailWebhook) eventHandler(w http.ResponseWriter, r *http.Request } pt.acc.AddFields("papertrail", fields, tags, e.ReceivedAt) } - } else if payload.Counts != nil { - // Handle count-based payload for _, c := range payload.Counts { for ts, count := range *c.TimeSeries { diff --git a/plugins/inputs/webhooks/webhooks.go b/plugins/inputs/webhooks/webhooks.go index 5c39903db..d54951bca 100644 --- a/plugins/inputs/webhooks/webhooks.go +++ b/plugins/inputs/webhooks/webhooks.go @@ -112,7 +112,6 @@ func (wb *Webhooks) Start(acc telegraf.Accumulator) error { ln, err := net.Listen("tcp", fmt.Sprintf("%s", wb.ServiceAddress)) if err != nil { return fmt.Errorf("error starting server: %v", err) - } go func() { diff --git a/plugins/inputs/x509_cert/x509_cert_test.go b/plugins/inputs/x509_cert/x509_cert_test.go index 0a0d0575a..35e41018d 100644 --- a/plugins/inputs/x509_cert/x509_cert_test.go +++ b/plugins/inputs/x509_cert/x509_cert_test.go @@ -305,7 +305,6 @@ func TestGatherChain(t *testing.T) { } }) } - } func TestStrings(t *testing.T) { diff --git a/plugins/outputs/application_insights/application_insights.go b/plugins/outputs/application_insights/application_insights.go index 5e41d629a..6bcb92486 100644 --- a/plugins/outputs/application_insights/application_insights.go +++ b/plugins/outputs/application_insights/application_insights.go @@ -222,8 +222,8 @@ func (a *ApplicationInsights) addContextTags(metric telegraf.Metric, telemetry a func getFloat64TelemetryPropertyValue( candidateFields []string, metric telegraf.Metric, - usedFields *[]string) (float64, error) { - + usedFields *[]string, +) (float64, error) { for _, fieldName := range candidateFields { fieldValue, found := metric.GetField(fieldName) if !found { @@ -248,8 +248,8 @@ func getFloat64TelemetryPropertyValue( func getIntTelemetryPropertyValue( candidateFields []string, metric telegraf.Metric, - usedFields *[]string) (int, error) { - + usedFields *[]string, +) (int, error) { for _, fieldName := range candidateFields { fieldValue, found := metric.GetField(fieldName) if !found { diff --git a/plugins/outputs/application_insights/application_insights_test.go b/plugins/outputs/application_insights/application_insights_test.go index 455344424..ceaad4a4e 100644 --- a/plugins/outputs/application_insights/application_insights_test.go +++ b/plugins/outputs/application_insights/application_insights_test.go @@ -397,7 +397,6 @@ func verifyAggregateTelemetry( countField string, telemetry *appinsights.AggregateMetricTelemetry, ) { - verifyAggregateField := func(fieldName string, telemetryValue float64) { metricRawFieldValue, found := metric.Fields()[fieldName] if !found { @@ -426,7 +425,6 @@ func verifySimpleTelemetry( expectedTelemetryName string, telemetry *appinsights.MetricTelemetry, ) { - assert.Equal(expectedTelemetryName, telemetry.Name, "Telemetry name is not what was expected") assert.EqualValues(metric.Fields()[valueField], telemetry.Value, "Telemetry value does not match metric value field") assert.Equal(metric.Time(), telemetry.Timestamp, "Telemetry and metric timestamps do not match") diff --git a/plugins/outputs/cloud_pubsub/pubsub_test.go b/plugins/outputs/cloud_pubsub/pubsub_test.go index 6911ef139..b3948573b 100644 --- a/plugins/outputs/cloud_pubsub/pubsub_test.go +++ b/plugins/outputs/cloud_pubsub/pubsub_test.go @@ -14,7 +14,6 @@ import ( ) func TestPubSub_WriteSingle(t *testing.T) { - testMetrics := []testMetric{ {testutil.TestMetric("value_1", "test"), false /*return error */}, } @@ -126,7 +125,6 @@ func TestPubSub_WriteOverByteThreshold(t *testing.T) { } func TestPubSub_WriteBase64Single(t *testing.T) { - testMetrics := []testMetric{ {testutil.TestMetric("value_1", "test"), false /*return error */}, {testutil.TestMetric("value_2", "test"), false}, diff --git a/plugins/outputs/cloudwatch/cloudwatch.go b/plugins/outputs/cloudwatch/cloudwatch.go index 82aebbdcc..3042a0b89 100644 --- a/plugins/outputs/cloudwatch/cloudwatch.go +++ b/plugins/outputs/cloudwatch/cloudwatch.go @@ -64,7 +64,6 @@ func (f *statisticField) addValue(sType statisticType, value float64) { } func (f *statisticField) buildDatum() []*cloudwatch.MetricDatum { - var datums []*cloudwatch.MetricDatum if f.hasAllFields() { @@ -88,7 +87,6 @@ func (f *statisticField) buildDatum() []*cloudwatch.MetricDatum { } datums = append(datums, datum) - } else { // If we don't have all required fields, we build each field as independent datum for sType, value := range f.values { @@ -120,7 +118,6 @@ func (f *statisticField) buildDatum() []*cloudwatch.MetricDatum { } func (f *statisticField) hasAllFields() bool { - _, hasMin := f.values[statisticTypeMin] _, hasMax := f.values[statisticTypeMax] _, hasSum := f.values[statisticTypeSum] @@ -145,7 +142,6 @@ func (f *valueField) addValue(sType statisticType, value float64) { } func (f *valueField) buildDatum() []*cloudwatch.MetricDatum { - return []*cloudwatch.MetricDatum{ { MetricName: aws.String(strings.Join([]string{f.metricName, f.fieldName}, "_")), @@ -226,7 +222,6 @@ func (c *CloudWatch) Close() error { } func (c *CloudWatch) Write(metrics []telegraf.Metric) error { - var datums []*cloudwatch.MetricDatum for _, m := range metrics { d := BuildMetricDatum(c.WriteStatistics, c.HighResolutionMetrics, m) @@ -263,7 +258,6 @@ func (c *CloudWatch) WriteToCloudWatch(datums []*cloudwatch.MetricDatum) error { // Partition the MetricDatums into smaller slices of a max size so that are under the limit // for the AWS API calls. func PartitionDatums(size int, datums []*cloudwatch.MetricDatum) [][]*cloudwatch.MetricDatum { - numberOfPartitions := len(datums) / size if len(datums)%size != 0 { numberOfPartitions++ @@ -288,7 +282,6 @@ func PartitionDatums(size int, datums []*cloudwatch.MetricDatum) [][]*cloudwatch // cloudwatch.StatisticSet are available. If so, it would build MetricDatum from statistic values. // Otherwise, fields would still been built independently. func BuildMetricDatum(buildStatistic bool, highResolutionMetrics bool, point telegraf.Metric) []*cloudwatch.MetricDatum { - fields := make(map[string]cloudwatchField) tags := point.Tags() storageResolution := int64(60) @@ -297,7 +290,6 @@ func BuildMetricDatum(buildStatistic bool, highResolutionMetrics bool, point tel } for k, v := range point.Fields() { - val, ok := convert(v) if !ok { // Only fields with values that can be converted to float64 (and within CloudWatch boundary) are supported. @@ -412,7 +404,6 @@ func getStatisticType(name string) (sType statisticType, fieldName string) { } func convert(v interface{}) (value float64, ok bool) { - ok = true switch t := v.(type) { diff --git a/plugins/outputs/cratedb/cratedb.go b/plugins/outputs/cratedb/cratedb.go index c520ee3d8..1c8aff47a 100644 --- a/plugins/outputs/cratedb/cratedb.go +++ b/plugins/outputs/cratedb/cratedb.go @@ -79,7 +79,6 @@ func (c *CrateDB) Write(metrics []telegraf.Metric) error { func insertSQL(table string, metrics []telegraf.Metric) (string, error) { rows := make([]string, len(metrics)) for i, m := range metrics { - cols := []interface{}{ hashID(m), m.Time().UTC(), diff --git a/plugins/outputs/elasticsearch/elasticsearch.go b/plugins/outputs/elasticsearch/elasticsearch.go index 97ef94bbb..c41495ec0 100644 --- a/plugins/outputs/elasticsearch/elasticsearch.go +++ b/plugins/outputs/elasticsearch/elasticsearch.go @@ -250,7 +250,6 @@ func (a *Elasticsearch) Connect() error { // GetPointID generates a unique ID for a Metric Point func GetPointID(m telegraf.Metric) string { - var buffer bytes.Buffer //Timestamp(ns),measurement name and Series Hash for compute the final SHA256 based hash ID @@ -294,7 +293,6 @@ func (a *Elasticsearch) Write(metrics []telegraf.Metric) error { } bulkRequest.Add(br) - } ctx, cancel := context.WithTimeout(context.Background(), a.Timeout.Duration) @@ -315,7 +313,6 @@ func (a *Elasticsearch) Write(metrics []telegraf.Metric) error { } return nil - } func (a *Elasticsearch) manageTemplate(ctx context.Context) error { @@ -360,17 +357,13 @@ func (a *Elasticsearch) manageTemplate(ctx context.Context) error { } log.Printf("D! Elasticsearch template %s created or updated\n", a.TemplateName) - } else { - log.Println("D! Found existing Elasticsearch template. Skipping template management") - } return nil } func (a *Elasticsearch) GetTagKeys(indexName string) (string, []string) { - tagKeys := []string{} startTag := strings.Index(indexName, "{{") @@ -379,7 +372,6 @@ func (a *Elasticsearch) GetTagKeys(indexName string) (string, []string) { if endTag < 0 { startTag = -1 - } else { tagName := indexName[startTag+2 : endTag] @@ -423,7 +415,6 @@ func (a *Elasticsearch) GetIndexName(indexName string, eventTime time.Time, tagK } return fmt.Sprintf(indexName, tagValues...) - } func getISOWeek(eventTime time.Time) string { diff --git a/plugins/outputs/elasticsearch/elasticsearch_test.go b/plugins/outputs/elasticsearch/elasticsearch_test.go index b0caf8448..d21d191cb 100644 --- a/plugins/outputs/elasticsearch/elasticsearch_test.go +++ b/plugins/outputs/elasticsearch/elasticsearch_test.go @@ -35,7 +35,6 @@ func TestConnectAndWriteIntegration(t *testing.T) { // Verify that we can successfully write data to Elasticsearch err = e.Write(testutil.MockMetrics()) require.NoError(t, err) - } func TestTemplateManagementEmptyTemplateIntegration(t *testing.T) { @@ -58,7 +57,6 @@ func TestTemplateManagementEmptyTemplateIntegration(t *testing.T) { err := e.manageTemplate(ctx) require.Error(t, err) - } func TestTemplateManagementIntegration(t *testing.T) { @@ -164,7 +162,6 @@ func TestGetTagKeys(t *testing.T) { t.Errorf("Expected tagKeys %s, got %s\n", test.ExpectedTagKeys, tagKeys) } } - } func TestGetIndexName(t *testing.T) { diff --git a/plugins/outputs/graphite/graphite.go b/plugins/outputs/graphite/graphite.go index ff26b24ba..455c7c785 100644 --- a/plugins/outputs/graphite/graphite.go +++ b/plugins/outputs/graphite/graphite.go @@ -189,9 +189,8 @@ func (g *Graphite) send(batch []byte) error { if _, e := g.conns[n].Write(batch); e != nil { // Error g.Log.Errorf("Graphite Error: " + e.Error()) - // Close explicitly + // Close explicitly and let's try the next one g.conns[n].Close() - // Let's try the next one } else { // Success err = nil diff --git a/plugins/outputs/graylog/graylog.go b/plugins/outputs/graylog/graylog.go index 34f2ec6d9..c6cad89c0 100644 --- a/plugins/outputs/graylog/graylog.go +++ b/plugins/outputs/graylog/graylog.go @@ -63,7 +63,6 @@ func (g *Gelf) Write(message []byte) (n int, err error) { length := compressed.Len() if length > chunksize { - chunkCountInt := int(math.Ceil(float64(length) / float64(chunksize))) id := make([]byte, 8) diff --git a/plugins/outputs/health/health.go b/plugins/outputs/health/health.go index e271b0b14..c7b584076 100644 --- a/plugins/outputs/health/health.go +++ b/plugins/outputs/health/health.go @@ -240,7 +240,6 @@ func (h *Health) getOrigin(listener net.Listener) string { } return origin.String() } - } func (h *Health) setHealthy(healthy bool) { diff --git a/plugins/outputs/influxdb/udp.go b/plugins/outputs/influxdb/udp.go index 0add3c6c3..510df9463 100644 --- a/plugins/outputs/influxdb/udp.go +++ b/plugins/outputs/influxdb/udp.go @@ -134,7 +134,6 @@ func scanLines(data []byte, atEOF bool) (advance int, token []byte, err error) { if i := bytes.IndexByte(data, '\n'); i >= 0 { // We have a full newline-terminated line. return i + 1, data[0 : i+1], nil - } return 0, nil, nil } diff --git a/plugins/outputs/kafka/kafka.go b/plugins/outputs/kafka/kafka.go index ceb2b93a6..dde2c8e62 100644 --- a/plugins/outputs/kafka/kafka.go +++ b/plugins/outputs/kafka/kafka.go @@ -66,7 +66,6 @@ func (*DebugLogger) Print(v ...interface{}) { args := make([]interface{}, 0, len(v)+1) args = append(append(args, "D! [sarama] "), v...) log.Print(args...) - } func (*DebugLogger) Printf(format string, v ...interface{}) { diff --git a/plugins/outputs/kinesis/kinesis.go b/plugins/outputs/kinesis/kinesis.go index 47d7aa10f..333214614 100644 --- a/plugins/outputs/kinesis/kinesis.go +++ b/plugins/outputs/kinesis/kinesis.go @@ -159,7 +159,6 @@ func (k *KinesisOutput) SetSerializer(serializer serializers.Serializer) { } func (k *KinesisOutput) writeKinesis(r []*kinesis.PutRecordsRequestEntry) time.Duration { - start := time.Now() payload := &kinesis.PutRecordsInput{ Records: r, @@ -252,7 +251,6 @@ func (k *KinesisOutput) Write(metrics []telegraf.Metric) error { sz = 0 r = nil } - } if sz > 0 { elapsed := k.writeKinesis(r) diff --git a/plugins/outputs/kinesis/kinesis_test.go b/plugins/outputs/kinesis/kinesis_test.go index 4c7063c40..24de7413c 100644 --- a/plugins/outputs/kinesis/kinesis_test.go +++ b/plugins/outputs/kinesis/kinesis_test.go @@ -19,7 +19,6 @@ import ( const zero int64 = 0 func TestPartitionKey(t *testing.T) { - assert := assert.New(t) testPoint := testutil.TestMetric(1) @@ -104,7 +103,6 @@ func TestPartitionKey(t *testing.T) { } func TestWriteKinesis_WhenSuccess(t *testing.T) { - assert := assert.New(t) partitionKey := "partitionKey" @@ -150,7 +148,6 @@ func TestWriteKinesis_WhenSuccess(t *testing.T) { } func TestWriteKinesis_WhenRecordErrors(t *testing.T) { - assert := assert.New(t) errorCode := "InternalFailure" @@ -196,7 +193,6 @@ func TestWriteKinesis_WhenRecordErrors(t *testing.T) { } func TestWriteKinesis_WhenServiceError(t *testing.T) { - assert := assert.New(t) partitionKey := "partitionKey" @@ -513,7 +509,6 @@ func (m *mockKinesisPutRecords) SetupResponse( failedRecordCount int64, records []*kinesis.PutRecordsResultEntry, ) { - m.responses = append(m.responses, &mockKinesisPutRecordsResponse{ Err: nil, Output: &kinesis.PutRecordsOutput{ @@ -527,7 +522,6 @@ func (m *mockKinesisPutRecords) SetupGenericResponse( successfulRecordCount uint32, failedRecordCount uint32, ) { - errorCode := "InternalFailure" errorMessage := "Internal Service Failure" shard := "shardId-000000000003" @@ -553,7 +547,6 @@ func (m *mockKinesisPutRecords) SetupGenericResponse( } func (m *mockKinesisPutRecords) SetupErrorResponse(err error) { - m.responses = append(m.responses, &mockKinesisPutRecordsResponse{ Err: err, Output: nil, @@ -561,7 +554,6 @@ func (m *mockKinesisPutRecords) SetupErrorResponse(err error) { } func (m *mockKinesisPutRecords) PutRecords(input *kinesis.PutRecordsInput) (*kinesis.PutRecordsOutput, error) { - reqNum := len(m.requests) if reqNum > len(m.responses) { return nil, fmt.Errorf("Response for request %+v not setup", reqNum) @@ -577,7 +569,6 @@ func (m *mockKinesisPutRecords) AssertRequests( assert *assert.Assertions, expected []*kinesis.PutRecordsInput, ) { - assert.Equal( len(expected), len(m.requests), @@ -628,7 +619,6 @@ func createTestMetric( name string, serializer serializers.Serializer, ) (telegraf.Metric, []byte) { - metric := testutil.TestMetric(1, name) data, err := serializer.Serialize(metric) @@ -642,7 +632,6 @@ func createTestMetrics( count uint32, serializer serializers.Serializer, ) ([]telegraf.Metric, [][]byte) { - metrics := make([]telegraf.Metric, count) metricsData := make([][]byte, count) @@ -660,7 +649,6 @@ func createPutRecordsRequestEntries( metricsData [][]byte, partitionKey *string, ) []*kinesis.PutRecordsRequestEntry { - count := len(metricsData) records := make([]*kinesis.PutRecordsRequestEntry, count) diff --git a/plugins/outputs/librato/librato.go b/plugins/outputs/librato/librato.go index 9f390046c..c91955ced 100644 --- a/plugins/outputs/librato/librato.go +++ b/plugins/outputs/librato/librato.go @@ -110,7 +110,6 @@ func (l *Librato) Write(metrics []telegraf.Metric) error { } else { l.Log.Infof("Unable to build Gauge for %s, skipping", m.Name()) l.Log.Debugf("Couldn't build gauge: %v", err) - } } @@ -192,7 +191,6 @@ func (l *Librato) buildGauges(m telegraf.Metric) ([]*Gauge, error) { fmt.Errorf("undeterminable Source type from Field, %s", l.Template) } for fieldName, value := range m.Fields() { - metricName := m.Name() if fieldName != "value" { metricName = fmt.Sprintf("%s.%s", m.Name(), fieldName) diff --git a/plugins/outputs/librato/librato_test.go b/plugins/outputs/librato/librato_test.go index 5e78d9645..5a425afca 100644 --- a/plugins/outputs/librato/librato_test.go +++ b/plugins/outputs/librato/librato_test.go @@ -64,7 +64,6 @@ func TestBadStatusCode(t *testing.T) { } func TestBuildGauge(t *testing.T) { - mtime := time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC).Unix() var gaugeTests = []struct { ptIn telegraf.Metric diff --git a/plugins/outputs/prometheus_client/v1/collector.go b/plugins/outputs/prometheus_client/v1/collector.go index 7932bbc59..a77f94d9f 100644 --- a/plugins/outputs/prometheus_client/v1/collector.go +++ b/plugins/outputs/prometheus_client/v1/collector.go @@ -153,7 +153,6 @@ func CreateSampleID(tags map[string]string) SampleID { } func addSample(fam *MetricFamily, sample *Sample, sampleID SampleID) { - for k := range sample.Labels { fam.LabelSet[k]++ } @@ -363,7 +362,6 @@ func (c *Collector) Add(metrics []telegraf.Metric) error { continue } c.addMetricFamily(point, sample, mname, sampleID) - } } } diff --git a/plugins/outputs/timestream/timestream_internal_test.go b/plugins/outputs/timestream/timestream_internal_test.go index 27b19487a..1f1194d70 100644 --- a/plugins/outputs/timestream/timestream_internal_test.go +++ b/plugins/outputs/timestream/timestream_internal_test.go @@ -36,7 +36,6 @@ func TestGetTimestreamTime(t *testing.T) { } func TestPartitionRecords(t *testing.T) { - assertions := assert.New(t) testDatum := timestreamwrite.Record{ diff --git a/plugins/outputs/warp10/warp10.go b/plugins/outputs/warp10/warp10.go index 1b2a31934..2e601fc16 100644 --- a/plugins/outputs/warp10/warp10.go +++ b/plugins/outputs/warp10/warp10.go @@ -106,9 +106,7 @@ func (w *Warp10) Connect() error { func (w *Warp10) GenWarp10Payload(metrics []telegraf.Metric) string { collectString := make([]string, 0) for _, mm := range metrics { - for _, field := range mm.FieldList() { - metric := &MetricLine{ Metric: fmt.Sprintf("%s%s", w.Prefix, mm.Name()+"."+field.Key), Timestamp: mm.Time().UnixNano() / 1000, @@ -171,7 +169,6 @@ func (w *Warp10) Write(metrics []telegraf.Metric) error { } func buildTags(tags []*telegraf.Tag) []string { - tagsString := make([]string, len(tags)+1) indexSource := 0 for index, tag := range tags { diff --git a/plugins/outputs/warp10/warp10_test.go b/plugins/outputs/warp10/warp10_test.go index 0b32ce4f1..afe931182 100644 --- a/plugins/outputs/warp10/warp10_test.go +++ b/plugins/outputs/warp10/warp10_test.go @@ -117,5 +117,4 @@ func TestHandleWarp10Error(t *testing.T) { payload := w.HandleError(handledError.Message, 511) require.Exactly(t, handledError.Expected, payload) } - } diff --git a/plugins/outputs/wavefront/wavefront.go b/plugins/outputs/wavefront/wavefront.go index 885bee8c0..f793d62b8 100644 --- a/plugins/outputs/wavefront/wavefront.go +++ b/plugins/outputs/wavefront/wavefront.go @@ -125,7 +125,6 @@ type MetricPoint struct { } func (w *Wavefront) Connect() error { - if len(w.StringToNumber) > 0 { w.Log.Warn("The string_to_number option is deprecated; please use the enum processor instead") } @@ -168,7 +167,6 @@ func (w *Wavefront) Connect() error { } func (w *Wavefront) Write(metrics []telegraf.Metric) error { - for _, m := range metrics { for _, point := range w.buildMetrics(m) { err := w.sender.SendMetric(point.Metric, point.Value, point.Timestamp, point.Source, point.Tags) @@ -233,7 +231,6 @@ func (w *Wavefront) buildMetrics(m telegraf.Metric) []*MetricPoint { } func (w *Wavefront) buildTags(mTags map[string]string) (string, map[string]string) { - // Remove all empty tags. for k, v := range mTags { if v == "" { diff --git a/plugins/outputs/wavefront/wavefront_test.go b/plugins/outputs/wavefront/wavefront_test.go index 40707e6d6..e96e05919 100644 --- a/plugins/outputs/wavefront/wavefront_test.go +++ b/plugins/outputs/wavefront/wavefront_test.go @@ -73,7 +73,6 @@ func TestBuildMetrics(t *testing.T) { } } } - } func TestBuildMetricsStrict(t *testing.T) { @@ -113,7 +112,6 @@ func TestBuildMetricsStrict(t *testing.T) { } } } - } func TestBuildMetricsWithSimpleFields(t *testing.T) { @@ -152,11 +150,9 @@ func TestBuildMetricsWithSimpleFields(t *testing.T) { } } } - } func TestBuildTags(t *testing.T) { - w := defaultWavefront() var tagtests = []struct { @@ -284,7 +280,6 @@ func TestBuildValue(t *testing.T) { t.Errorf("\nexpected\t%+v\nreceived\t%+v\n", vt.out, value) } } - } func TestBuildValueString(t *testing.T) { @@ -315,7 +310,6 @@ func TestBuildValueString(t *testing.T) { t.Errorf("\nexpected\t%+v\nreceived\t%+v\n", vt.out, value) } } - } func TestTagLimits(t *testing.T) { diff --git a/plugins/parsers/dropwizard/parser.go b/plugins/parsers/dropwizard/parser.go index d8dcc9204..179de7dd7 100644 --- a/plugins/parsers/dropwizard/parser.go +++ b/plugins/parsers/dropwizard/parser.go @@ -69,7 +69,6 @@ func NewParser() *parser { // Parse parses the input bytes to an array of metrics func (p *parser) Parse(buf []byte) ([]telegraf.Metric, error) { - metrics := make([]telegraf.Metric, 0) metricTime, err := p.parseTime(buf) @@ -147,7 +146,6 @@ func (p *parser) SetDefaultTags(tags map[string]string) { } func (p *parser) readTags(buf []byte) map[string]string { - if p.TagsPath != "" { var tagsBytes []byte tagsResult := gjson.GetBytes(buf, p.TagsPath) @@ -173,7 +171,6 @@ func (p *parser) readTags(buf []byte) map[string]string { } func (p *parser) parseTime(buf []byte) (time.Time, error) { - if p.TimePath != "" { timeFormat := p.TimeFormat if timeFormat == "" { @@ -195,7 +192,6 @@ func (p *parser) parseTime(buf []byte) (time.Time, error) { } func (p *parser) unmarshalMetrics(buf []byte) (map[string]interface{}, error) { - var registryBytes []byte if p.MetricRegistryPath != "" { regResult := gjson.GetBytes(buf, p.MetricRegistryPath) diff --git a/plugins/parsers/grok/parser.go b/plugins/parsers/grok/parser.go index cdf787d8f..7037473e8 100644 --- a/plugins/parsers/grok/parser.go +++ b/plugins/parsers/grok/parser.go @@ -377,7 +377,6 @@ func (p *Parser) ParseLine(line string) (telegraf.Metric, error) { } func (p *Parser) Parse(buf []byte) ([]telegraf.Metric, error) { - metrics := make([]telegraf.Metric, 0) scanner := bufio.NewScanner(bytes.NewReader(buf)) diff --git a/plugins/parsers/grok/parser_test.go b/plugins/parsers/grok/parser_test.go index 1c409e8a5..d51f30385 100644 --- a/plugins/parsers/grok/parser_test.go +++ b/plugins/parsers/grok/parser_test.go @@ -1013,7 +1013,6 @@ func TestSyslogTimestamp(t *testing.T) { } func TestReplaceTimestampComma(t *testing.T) { - p := &Parser{ Patterns: []string{`%{TIMESTAMP_ISO8601:timestamp:ts-"2006-01-02 15:04:05.000"} successfulMatches=%{NUMBER:value:int}`}, } diff --git a/plugins/parsers/json/parser.go b/plugins/parsers/json/parser.go index e8a748e70..1830e2a6a 100644 --- a/plugins/parsers/json/parser.go +++ b/plugins/parsers/json/parser.go @@ -88,7 +88,6 @@ func (p *Parser) parseArray(data []interface{}, timestamp time.Time) ([]telegraf results = append(results, metrics...) default: return nil, ErrWrongType - } } @@ -155,7 +154,6 @@ func (p *Parser) parseObject(data map[string]interface{}, timestamp time.Time) ( // will delete any strings/bools that shouldn't be fields // assumes that any non-numeric values in TagKeys should be displayed as tags func (p *Parser) switchFieldToTag(tags map[string]string, fields map[string]interface{}) (map[string]string, map[string]interface{}) { - for name, value := range fields { if p.tagKeys == nil { continue diff --git a/plugins/parsers/json/parser_test.go b/plugins/parsers/json/parser_test.go index 525c8fd28..9abe853ec 100644 --- a/plugins/parsers/json/parser_test.go +++ b/plugins/parsers/json/parser_test.go @@ -1357,5 +1357,4 @@ func TestParseArrayWithWildcardTagKeys(t *testing.T) { testutil.RequireMetricsEqual(t, tt.expected, actual, testutil.IgnoreTime()) }) } - } diff --git a/plugins/parsers/wavefront/element.go b/plugins/parsers/wavefront/element.go index 7c9487369..86fd166ff 100644 --- a/plugins/parsers/wavefront/element.go +++ b/plugins/parsers/wavefront/element.go @@ -108,7 +108,6 @@ func (ep *TimestampParser) parse(p *PointParser, pt *Point) error { } func setTimestamp(pt *Point, ts int64, numDigits int) error { - if numDigits == 19 { // nanoseconds ts = ts / 1e9 diff --git a/plugins/parsers/wavefront/parser.go b/plugins/parsers/wavefront/parser.go index d7984fb99..5fba2d5de 100644 --- a/plugins/parsers/wavefront/parser.go +++ b/plugins/parsers/wavefront/parser.go @@ -90,7 +90,6 @@ func (p *WavefrontParser) Parse(buf []byte) ([]telegraf.Metric, error) { } func (p *PointParser) Parse(buf []byte) ([]telegraf.Metric, error) { - // parse even if the buffer begins with a newline buf = bytes.TrimPrefix(buf, []byte("\n")) // add newline to end if not exists: @@ -133,7 +132,6 @@ func (p *WavefrontParser) SetDefaultTags(tags map[string]string) { } func (p *PointParser) convertPointToTelegrafMetric(points []Point) ([]telegraf.Metric, error) { - metrics := make([]telegraf.Metric, 0) for _, point := range points { @@ -211,7 +209,6 @@ func (p *PointParser) unscanTokens(n int) { } func (p *PointParser) reset(buf []byte) { - // reset the scan buffer and write new byte p.scanBuf.Reset() p.scanBuf.Write(buf) diff --git a/plugins/parsers/wavefront/parser_test.go b/plugins/parsers/wavefront/parser_test.go index fed31b5f2..1f1801730 100644 --- a/plugins/parsers/wavefront/parser_test.go +++ b/plugins/parsers/wavefront/parser_test.go @@ -86,7 +86,6 @@ func TestParse(t *testing.T) { testMetric, err = metric.New("test.metric", map[string]string{"source": "mysource", "tag2": "value2"}, map[string]interface{}{"value": 1.1234}, time.Unix(1530939936, 0)) assert.NoError(t, err) assert.EqualValues(t, parsedMetrics[0], testMetric) - } func TestParseLine(t *testing.T) { @@ -172,7 +171,6 @@ func TestParseMultiple(t *testing.T) { assert.NoError(t, err) testMetrics = []telegraf.Metric{testMetric1, testMetric2, testMetric3} assert.EqualValues(t, parsedMetrics, testMetrics) - } func TestParseSpecial(t *testing.T) { @@ -189,7 +187,6 @@ func TestParseSpecial(t *testing.T) { testMetric, err = metric.New("test.metric", map[string]string{"tag1": "val\\\"ue1"}, map[string]interface{}{"value": 1.}, time.Unix(1530939936, 0)) assert.NoError(t, err) assert.EqualValues(t, parsedMetric, testMetric) - } func TestParseInvalid(t *testing.T) { @@ -221,7 +218,6 @@ func TestParseInvalid(t *testing.T) { _, err = parser.Parse([]byte("\"test.metric\" -1.12-34 1530939936 \"source\"=\"mysource\" tag2=value2")) assert.Error(t, err) - } func TestParseDefaultTags(t *testing.T) { @@ -244,5 +240,4 @@ func TestParseDefaultTags(t *testing.T) { testMetric, err = metric.New("test.metric", map[string]string{"myDefault": "value1", "another": "test2"}, map[string]interface{}{"value": 1.1234}, time.Unix(1530939936, 0)) assert.NoError(t, err) assert.EqualValues(t, parsedMetrics[0], testMetric) - } diff --git a/plugins/parsers/wavefront/scanner.go b/plugins/parsers/wavefront/scanner.go index abdbd6d1b..5d22c5389 100644 --- a/plugins/parsers/wavefront/scanner.go +++ b/plugins/parsers/wavefront/scanner.go @@ -31,7 +31,6 @@ func (s *PointScanner) unread() { // Scan returns the next token and literal value. func (s *PointScanner) Scan() (Token, string) { - // Read the next rune ch := s.read() if isWhitespace(ch) { diff --git a/plugins/processors/date/date_test.go b/plugins/processors/date/date_test.go index 42e094c93..9bafc0654 100644 --- a/plugins/processors/date/date_test.go +++ b/plugins/processors/date/date_test.go @@ -30,7 +30,6 @@ func TestTagAndField(t *testing.T) { } err := dateFormatTagAndField.Init() require.Error(t, err) - } func TestNoOutputSpecified(t *testing.T) { diff --git a/plugins/processors/filepath/filepath.go b/plugins/processors/filepath/filepath.go index 70013de17..26a0a7abd 100644 --- a/plugins/processors/filepath/filepath.go +++ b/plugins/processors/filepath/filepath.go @@ -95,7 +95,6 @@ func (o *Options) applyFunc(bo BaseOpts, fn ProcessorFunc, metric telegraf.Metri if v, ok := v.(string); ok { metric.AddField(targetField, fn(v)) } - } } } diff --git a/plugins/processors/port_name/port_name.go b/plugins/processors/port_name/port_name.go index 7fc459c03..60817dbdd 100644 --- a/plugins/processors/port_name/port_name.go +++ b/plugins/processors/port_name/port_name.go @@ -108,7 +108,6 @@ func readServices(r io.Reader) sMap { func (pn *PortName) Apply(metrics ...telegraf.Metric) []telegraf.Metric { for _, m := range metrics { - var portProto string var fromField bool diff --git a/plugins/processors/starlark/builtins.go b/plugins/processors/starlark/builtins.go index 66a7c9f9e..53e31fb3a 100644 --- a/plugins/processors/starlark/builtins.go +++ b/plugins/processors/starlark/builtins.go @@ -191,7 +191,6 @@ func dictUpdate(b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tupl iter2 := starlark.Iterate(pair) if iter2 == nil { return nil, fmt.Errorf("dictionary update sequence element #%d is not iterable (%s)", i, pair.Type()) - } defer iter2.Done() len := starlark.Len(pair) diff --git a/plugins/processors/topk/topk.go b/plugins/processors/topk/topk.go index 765328372..24e1f7c95 100644 --- a/plugins/processors/topk/topk.go +++ b/plugins/processors/topk/topk.go @@ -280,7 +280,6 @@ func (t *TopK) push() []telegraf.Metric { // Get the top K metrics for each field and add them to the return value addedKeys := make(map[string]bool) for _, field := range t.Fields { - // Sort the aggregations sortMetrics(aggregations, field, t.Bottomk) diff --git a/plugins/processors/topk/topk_test.go b/plugins/processors/topk/topk_test.go index 928111b29..858859de6 100644 --- a/plugins/processors/topk/topk_test.go +++ b/plugins/processors/topk/topk_test.go @@ -139,7 +139,6 @@ func runAndCompare(topk *TopK, metrics []telegraf.Metric, answer []telegraf.Metr // Smoke tests func TestTopkAggregatorsSmokeTests(t *testing.T) { - // Build the processor var topk TopK topk = *New() @@ -162,7 +161,6 @@ func TestTopkAggregatorsSmokeTests(t *testing.T) { // AddAggregateFields + Mean aggregator func TestTopkMeanAddAggregateFields(t *testing.T) { - // Build the processor var topk TopK topk = *New() @@ -192,7 +190,6 @@ func TestTopkMeanAddAggregateFields(t *testing.T) { // AddAggregateFields + Sum aggregator func TestTopkSumAddAggregateFields(t *testing.T) { - // Build the processor var topk TopK topk = *New() @@ -222,7 +219,6 @@ func TestTopkSumAddAggregateFields(t *testing.T) { // AddAggregateFields + Max aggregator func TestTopkMaxAddAggregateFields(t *testing.T) { - // Build the processor var topk TopK topk = *New() @@ -252,7 +248,6 @@ func TestTopkMaxAddAggregateFields(t *testing.T) { // AddAggregateFields + Min aggregator func TestTopkMinAddAggregateFields(t *testing.T) { - // Build the processor var topk TopK topk = *New() @@ -282,7 +277,6 @@ func TestTopkMinAddAggregateFields(t *testing.T) { // GroupBy func TestTopkGroupby1(t *testing.T) { - // Build the processor var topk TopK topk = *New() @@ -308,7 +302,6 @@ func TestTopkGroupby1(t *testing.T) { runAndCompare(&topk, input, answer, "GroupBy test 1", t) } func TestTopkGroupby2(t *testing.T) { - // Build the processor var topk TopK topk = *New() @@ -338,7 +331,6 @@ func TestTopkGroupby2(t *testing.T) { runAndCompare(&topk, input, answer, "GroupBy test 2", t) } func TestTopkGroupby3(t *testing.T) { - // Build the processor var topk TopK topk = *New() @@ -365,7 +357,6 @@ func TestTopkGroupby3(t *testing.T) { // GroupBy + Fields func TestTopkGroupbyFields1(t *testing.T) { - // Build the processor var topk TopK topk = *New() @@ -393,7 +384,6 @@ func TestTopkGroupbyFields1(t *testing.T) { } func TestTopkGroupbyFields2(t *testing.T) { - // Build the processor var topk TopK topk = *New() @@ -422,7 +412,6 @@ func TestTopkGroupbyFields2(t *testing.T) { // GroupBy metric name func TestTopkGroupbyMetricName1(t *testing.T) { - // Build the processor var topk TopK topk = *New() @@ -449,7 +438,6 @@ func TestTopkGroupbyMetricName1(t *testing.T) { } func TestTopkGroupbyMetricName2(t *testing.T) { - // Build the processor var topk TopK topk = *New() @@ -478,7 +466,6 @@ func TestTopkGroupbyMetricName2(t *testing.T) { // BottomK func TestTopkBottomk(t *testing.T) { - // Build the processor var topk TopK topk = *New() @@ -505,7 +492,6 @@ func TestTopkBottomk(t *testing.T) { // GroupByKeyTag func TestTopkGroupByKeyTag(t *testing.T) { - // Build the processor var topk TopK topk = *New() diff --git a/plugins/serializers/msgpack/msgpack.go b/plugins/serializers/msgpack/msgpack.go index d850bb8b0..cd5f6ceb2 100644 --- a/plugins/serializers/msgpack/msgpack.go +++ b/plugins/serializers/msgpack/msgpack.go @@ -38,7 +38,6 @@ func (s *Serializer) SerializeBatch(metrics []telegraf.Metric) ([]byte, error) { if err != nil { return nil, err } - } return buf, nil } diff --git a/plugins/serializers/prometheus/collection.go b/plugins/serializers/prometheus/collection.go index d37ecaaaf..ed442e23c 100644 --- a/plugins/serializers/prometheus/collection.go +++ b/plugins/serializers/prometheus/collection.go @@ -168,7 +168,6 @@ func (c *Collection) createLabels(metric telegraf.Metric) []LabelPair { labels = append(labels, LabelPair{Name: name, Value: value}) addedFieldLabel = true - } if addedFieldLabel { @@ -201,7 +200,6 @@ func (c *Collection) Add(metric telegraf.Metric, now time.Time) { Metrics: make(map[MetricKey]*Metric), } c.Entries[family] = entry - } metricKey := MakeMetricKey(labels) diff --git a/plugins/serializers/prometheusremotewrite/prometheusremotewrite.go b/plugins/serializers/prometheusremotewrite/prometheusremotewrite.go index a2dfee71f..670d3d346 100644 --- a/plugins/serializers/prometheusremotewrite/prometheusremotewrite.go +++ b/plugins/serializers/prometheusremotewrite/prometheusremotewrite.go @@ -201,7 +201,6 @@ func (s *Serializer) SerializeBatch(metrics []telegraf.Metric) ([]byte, error) { } entries[metrickey] = promts } - } var promTS = make([]*prompb.TimeSeries, len(entries)) @@ -235,7 +234,6 @@ func (s *Serializer) SerializeBatch(metrics []telegraf.Metric) ([]byte, error) { return false }) - } data, err := proto.Marshal(&prompb.WriteRequest{Timeseries: promTS}) if err != nil { @@ -302,7 +300,6 @@ func (s *Serializer) createLabels(metric telegraf.Metric) []*prompb.Label { labels = append(labels, &prompb.Label{Name: name, Value: value}) addedFieldLabel = true - } if addedFieldLabel { diff --git a/plugins/serializers/splunkmetric/splunkmetric.go b/plugins/serializers/splunkmetric/splunkmetric.go index f23de80df..f3a3ecebc 100644 --- a/plugins/serializers/splunkmetric/splunkmetric.go +++ b/plugins/serializers/splunkmetric/splunkmetric.go @@ -40,7 +40,6 @@ func NewSerializer(splunkmetricHecRouting bool, splunkmetricMultimetric bool) (* } func (s *serializer) Serialize(metric telegraf.Metric) ([]byte, error) { - m, err := s.createObject(metric) if err != nil { return nil, fmt.Errorf("D! [serializer.splunkmetric] Dropping invalid metric: %s", metric.Name()) @@ -50,7 +49,6 @@ func (s *serializer) Serialize(metric telegraf.Metric) ([]byte, error) { } func (s *serializer) SerializeBatch(metrics []telegraf.Metric) ([]byte, error) { - var serialized []byte for _, metric := range metrics { @@ -121,7 +119,6 @@ func (s *serializer) createSingle(metric telegraf.Metric, dataGroup HECTimeSerie var metricJSON []byte for _, field := range metric.FieldList() { - value, valid := verifyValue(field.Value) if !valid { @@ -161,7 +158,6 @@ func (s *serializer) createSingle(metric telegraf.Metric, dataGroup HECTimeSerie } func (s *serializer) createObject(metric telegraf.Metric) (metricGroup []byte, err error) { - /* Splunk supports one metric json object, and does _not_ support an array of JSON objects. ** Splunk has the following required names for the metric store: ** metric_name: The name of the metric diff --git a/testutil/accumulator.go b/testutil/accumulator.go index f1b6469b7..c09857d15 100644 --- a/testutil/accumulator.go +++ b/testutil/accumulator.go @@ -119,7 +119,6 @@ func (a *Accumulator) addFields( } else { t = a.TimeFunc() } - } if a.debug { diff --git a/testutil/testutil_test.go b/testutil/testutil_test.go index 52a807514..e401b10a7 100644 --- a/testutil/testutil_test.go +++ b/testutil/testutil_test.go @@ -6,7 +6,6 @@ import ( ) func TestDockerHost(t *testing.T) { - os.Unsetenv("DOCKER_HOST") host := GetLocalHost() @@ -30,5 +29,4 @@ func TestDockerHost(t *testing.T) { if host != "1.1.1.1" { t.Fatalf("Host should take DOCKER_HOST value when set. Current value is [%s] and DOCKER_HOST is [%s]", host, os.Getenv("DOCKER_HOST")) } - }