Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit a9b1ab1

Browse files
authored
Merge pull request google#1374 from timstclair/comments
Cleanup comment style: // should be proceeded by a space
2 parents 0c6b72d + afe67fe commit a9b1ab1

File tree

13 files changed

+62
-62
lines changed

13 files changed

+62
-62
lines changed

collector/config.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,43 +22,43 @@ import (
2222
)
2323

2424
type Config struct {
25-
//the endpoint to hit to scrape metrics
25+
// the endpoint to hit to scrape metrics
2626
Endpoint EndpointConfig `json:"endpoint"`
2727

28-
//holds information about different metrics that can be collected
28+
// holds information about different metrics that can be collected
2929
MetricsConfig []MetricConfig `json:"metrics_config"`
3030
}
3131

3232
// metricConfig holds information extracted from the config file about a metric
3333
type MetricConfig struct {
34-
//the name of the metric
34+
// the name of the metric
3535
Name string `json:"name"`
3636

37-
//enum type for the metric type
37+
// enum type for the metric type
3838
MetricType v1.MetricType `json:"metric_type"`
3939

4040
// metric units to display on UI and in storage (eg: MB, cores)
4141
// this is only used for display.
4242
Units string `json:"units"`
4343

44-
//data type of the metric (eg: int, float)
44+
// data type of the metric (eg: int, float)
4545
DataType v1.DataType `json:"data_type"`
4646

47-
//the frequency at which the metric should be collected
47+
// the frequency at which the metric should be collected
4848
PollingFrequency time.Duration `json:"polling_frequency"`
4949

50-
//the regular expression that can be used to extract the metric
50+
// the regular expression that can be used to extract the metric
5151
Regex string `json:"regex"`
5252
}
5353

5454
type Prometheus struct {
55-
//the endpoint to hit to scrape metrics
55+
// the endpoint to hit to scrape metrics
5656
Endpoint EndpointConfig `json:"endpoint"`
5757

58-
//the frequency at which metrics should be collected
58+
// the frequency at which metrics should be collected
5959
PollingFrequency time.Duration `json:"polling_frequency"`
6060

61-
//holds names of different metrics that can be collected
61+
// holds names of different metrics that can be collected
6262
MetricsConfig []string `json:"metrics_config"`
6363
}
6464

collector/generic_collector.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,32 +29,32 @@ import (
2929
)
3030

3131
type GenericCollector struct {
32-
//name of the collector
32+
// name of the collector
3333
name string
3434

35-
//holds information extracted from the config file for a collector
35+
// holds information extracted from the config file for a collector
3636
configFile Config
3737

38-
//holds information necessary to extract metrics
38+
// holds information necessary to extract metrics
3939
info *collectorInfo
4040

4141
// The Http client to use when connecting to metric endpoints
4242
httpClient *http.Client
4343
}
4444

4545
type collectorInfo struct {
46-
//minimum polling frequency among all metrics
46+
// minimum polling frequency among all metrics
4747
minPollingFrequency time.Duration
4848

49-
//regular expresssions for all metrics
49+
// regular expresssions for all metrics
5050
regexps []*regexp.Regexp
5151

5252
// Limit for the number of srcaped metrics. If the count is higher,
5353
// no metrics will be returned.
5454
metricCountLimit int
5555
}
5656

57-
//Returns a new collector using the information extracted from the configfile
57+
// Returns a new collector using the information extracted from the configfile
5858
func NewCollector(collectorName string, configFile []byte, metricCountLimit int, containerHandler container.ContainerHandler, httpClient *http.Client) (*GenericCollector, error) {
5959
var configInJSON Config
6060
err := json.Unmarshal(configFile, &configInJSON)
@@ -64,7 +64,7 @@ func NewCollector(collectorName string, configFile []byte, metricCountLimit int,
6464

6565
configInJSON.Endpoint.configure(containerHandler)
6666

67-
//TODO : Add checks for validity of config file (eg : Accurate JSON fields)
67+
// TODO : Add checks for validity of config file (eg : Accurate JSON fields)
6868

6969
if len(configInJSON.MetricsConfig) == 0 {
7070
return nil, fmt.Errorf("No metrics provided in config")
@@ -109,7 +109,7 @@ func NewCollector(collectorName string, configFile []byte, metricCountLimit int,
109109
}, nil
110110
}
111111

112-
//Returns name of the collector
112+
// Returns name of the collector
113113
func (collector *GenericCollector) Name() string {
114114
return collector.name
115115
}
@@ -132,7 +132,7 @@ func (collector *GenericCollector) GetSpec() []v1.MetricSpec {
132132
return specs
133133
}
134134

135-
//Returns collected metrics and the next collection time of the collector
135+
// Returns collected metrics and the next collection time of the collector
136136
func (collector *GenericCollector) Collect(metrics map[string][]v1.MetricVal) (time.Time, map[string][]v1.MetricVal, error) {
137137
currentTime := time.Now()
138138
nextCollectionTime := currentTime.Add(time.Duration(collector.info.minPollingFrequency))

collector/generic_collector_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func TestEmptyConfig(t *testing.T) {
3939
}
4040
`
4141

42-
//Create a temporary config file 'temp.json' with invalid json format
42+
// Create a temporary config file 'temp.json' with invalid json format
4343
assert.NoError(ioutil.WriteFile("temp.json", []byte(emptyConfig), 0777))
4444

4545
configFile, err := ioutil.ReadFile("temp.json")
@@ -55,7 +55,7 @@ func TestEmptyConfig(t *testing.T) {
5555
func TestConfigWithErrors(t *testing.T) {
5656
assert := assert.New(t)
5757

58-
//Syntax error: Missed '"' after activeConnections
58+
// Syntax error: Missed '"' after activeConnections
5959
invalid := `
6060
{
6161
"endpoint" : "http://localhost:8000/nginx_status",
@@ -71,7 +71,7 @@ func TestConfigWithErrors(t *testing.T) {
7171
}
7272
`
7373

74-
//Create a temporary config file 'temp.json' with invalid json format
74+
// Create a temporary config file 'temp.json' with invalid json format
7575
assert.NoError(ioutil.WriteFile("temp.json", []byte(invalid), 0777))
7676
configFile, err := ioutil.ReadFile("temp.json")
7777
assert.NoError(err)
@@ -86,7 +86,7 @@ func TestConfigWithErrors(t *testing.T) {
8686
func TestConfigWithRegexErrors(t *testing.T) {
8787
assert := assert.New(t)
8888

89-
//Error: Missed operand for '+' in activeConnections regex
89+
// Error: Missed operand for '+' in activeConnections regex
9090
invalid := `
9191
{
9292
"endpoint" : "host:port/nginx_status",
@@ -109,7 +109,7 @@ func TestConfigWithRegexErrors(t *testing.T) {
109109
}
110110
`
111111

112-
//Create a temporary config file 'temp.json'
112+
// Create a temporary config file 'temp.json'
113113
assert.NoError(ioutil.WriteFile("temp.json", []byte(invalid), 0777))
114114

115115
configFile, err := ioutil.ReadFile("temp.json")
@@ -125,7 +125,7 @@ func TestConfigWithRegexErrors(t *testing.T) {
125125
func TestConfig(t *testing.T) {
126126
assert := assert.New(t)
127127

128-
//Create an nginx collector using the config file 'sample_config.json'
128+
// Create an nginx collector using the config file 'sample_config.json'
129129
configFile, err := ioutil.ReadFile("config/sample_config.json")
130130
assert.NoError(err)
131131

@@ -157,7 +157,7 @@ func TestEndpointConfig(t *testing.T) {
157157
func TestMetricCollection(t *testing.T) {
158158
assert := assert.New(t)
159159

160-
//Collect nginx metrics from a fake nginx endpoint
160+
// Collect nginx metrics from a fake nginx endpoint
161161
configFile, err := ioutil.ReadFile("config/sample_config.json")
162162
assert.NoError(err)
163163

@@ -193,7 +193,7 @@ func TestMetricCollection(t *testing.T) {
193193
func TestMetricCollectionLimit(t *testing.T) {
194194
assert := assert.New(t)
195195

196-
//Collect nginx metrics from a fake nginx endpoint
196+
// Collect nginx metrics from a fake nginx endpoint
197197
configFile, err := ioutil.ReadFile("config/sample_config.json")
198198
assert.NoError(err)
199199

collector/prometheus_collector.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ import (
3232
)
3333

3434
type PrometheusCollector struct {
35-
//name of the collector
35+
// name of the collector
3636
name string
3737

38-
//rate at which metrics are collected
38+
// rate at which metrics are collected
3939
pollingFrequency time.Duration
4040

41-
//holds information extracted from the config file for a collector
41+
// holds information extracted from the config file for a collector
4242
configFile Prometheus
4343

4444
// the metrics to gather (uses a map as a set)
@@ -52,7 +52,7 @@ type PrometheusCollector struct {
5252
httpClient *http.Client
5353
}
5454

55-
//Returns a new collector using the information extracted from the configfile
55+
// Returns a new collector using the information extracted from the configfile
5656
func NewPrometheusCollector(collectorName string, configFile []byte, metricCountLimit int, containerHandler container.ContainerHandler, httpClient *http.Client) (*PrometheusCollector, error) {
5757
var configInJSON Prometheus
5858
err := json.Unmarshal(configFile, &configInJSON)
@@ -87,7 +87,7 @@ func NewPrometheusCollector(collectorName string, configFile []byte, metricCount
8787
return nil, fmt.Errorf("Too many metrics defined: %d limit %d", len(configInJSON.MetricsConfig), metricCountLimit)
8888
}
8989

90-
//TODO : Add checks for validity of config file (eg : Accurate JSON fields)
90+
// TODO : Add checks for validity of config file (eg : Accurate JSON fields)
9191
return &PrometheusCollector{
9292
name: collectorName,
9393
pollingFrequency: minPollingFrequency,
@@ -98,7 +98,7 @@ func NewPrometheusCollector(collectorName string, configFile []byte, metricCount
9898
}, nil
9999
}
100100

101-
//Returns name of the collector
101+
// Returns name of the collector
102102
func (collector *PrometheusCollector) Name() string {
103103
return collector.name
104104
}
@@ -201,7 +201,7 @@ func prometheusLabelSetToCadvisorLabel(promLabels model.Metric) string {
201201
return string(b.Bytes())
202202
}
203203

204-
//Returns collected metrics and the next collection time of the collector
204+
// Returns collected metrics and the next collection time of the collector
205205
func (collector *PrometheusCollector) Collect(metrics map[string][]v1.MetricVal) (time.Time, map[string][]v1.MetricVal, error) {
206206
currentTime := time.Now()
207207
nextCollectionTime := currentTime.Add(time.Duration(collector.pollingFrequency))

collector/prometheus_collector_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131
func TestPrometheus(t *testing.T) {
3232
assert := assert.New(t)
3333

34-
//Create a prometheus collector using the config file 'sample_config_prometheus.json'
34+
// Create a prometheus collector using the config file 'sample_config_prometheus.json'
3535
configFile, err := ioutil.ReadFile("config/sample_config_prometheus.json")
3636
containerHandler := containertest.NewMockContainerHandler("mockContainer")
3737
collector, err := NewPrometheusCollector("Prometheus", configFile, 100, containerHandler, http.DefaultClient)
@@ -130,7 +130,7 @@ func TestPrometheusEndpointConfig(t *testing.T) {
130130
func TestPrometheusShortResponse(t *testing.T) {
131131
assert := assert.New(t)
132132

133-
//Create a prometheus collector using the config file 'sample_config_prometheus.json'
133+
// Create a prometheus collector using the config file 'sample_config_prometheus.json'
134134
configFile, err := ioutil.ReadFile("config/sample_config_prometheus.json")
135135
containerHandler := containertest.NewMockContainerHandler("mockContainer")
136136
collector, err := NewPrometheusCollector("Prometheus", configFile, 100, containerHandler, http.DefaultClient)
@@ -153,7 +153,7 @@ func TestPrometheusShortResponse(t *testing.T) {
153153
func TestPrometheusMetricCountLimit(t *testing.T) {
154154
assert := assert.New(t)
155155

156-
//Create a prometheus collector using the config file 'sample_config_prometheus.json'
156+
// Create a prometheus collector using the config file 'sample_config_prometheus.json'
157157
configFile, err := ioutil.ReadFile("config/sample_config_prometheus.json")
158158
containerHandler := containertest.NewMockContainerHandler("mockContainer")
159159
collector, err := NewPrometheusCollector("Prometheus", configFile, 10, containerHandler, http.DefaultClient)
@@ -182,7 +182,7 @@ func TestPrometheusMetricCountLimit(t *testing.T) {
182182
func TestPrometheusFiltersMetrics(t *testing.T) {
183183
assert := assert.New(t)
184184

185-
//Create a prometheus collector using the config file 'sample_config_prometheus_filtered.json'
185+
// Create a prometheus collector using the config file 'sample_config_prometheus_filtered.json'
186186
configFile, err := ioutil.ReadFile("config/sample_config_prometheus_filtered.json")
187187
containerHandler := containertest.NewMockContainerHandler("mockContainer")
188188
collector, err := NewPrometheusCollector("Prometheus", configFile, 100, containerHandler, http.DefaultClient)
@@ -221,7 +221,7 @@ go_goroutines 16
221221
func TestPrometheusFiltersMetricsCountLimit(t *testing.T) {
222222
assert := assert.New(t)
223223

224-
//Create a prometheus collector using the config file 'sample_config_prometheus_filtered.json'
224+
// Create a prometheus collector using the config file 'sample_config_prometheus_filtered.json'
225225
configFile, err := ioutil.ReadFile("config/sample_config_prometheus_filtered.json")
226226
containerHandler := containertest.NewMockContainerHandler("mockContainer")
227227
_, err = NewPrometheusCollector("Prometheus", configFile, 1, containerHandler, http.DefaultClient)

container/rkt/handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func newRktContainerHandler(name string, rktClient rktapi.PublicAPIClient, rktPa
8484
return nil, fmt.Errorf("this should be impossible!, new handler failing, but factory allowed, name = %s", name)
8585
}
8686

87-
//rktnetes uses containerID: rkt://fff40827-b994-4e3a-8f88-6427c2c8a5ac:nginx
87+
// rktnetes uses containerID: rkt://fff40827-b994-4e3a-8f88-6427c2c8a5ac:nginx
8888
if parsed.Container == "" {
8989
isPod = true
9090
aliases = append(aliases, "rkt://"+parsed.Pod)

info/v1/container.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -389,27 +389,27 @@ type NetworkStats struct {
389389
}
390390

391391
type TcpStat struct {
392-
//Count of TCP connections in state "Established"
392+
// Count of TCP connections in state "Established"
393393
Established uint64
394-
//Count of TCP connections in state "Syn_Sent"
394+
// Count of TCP connections in state "Syn_Sent"
395395
SynSent uint64
396-
//Count of TCP connections in state "Syn_Recv"
396+
// Count of TCP connections in state "Syn_Recv"
397397
SynRecv uint64
398-
//Count of TCP connections in state "Fin_Wait1"
398+
// Count of TCP connections in state "Fin_Wait1"
399399
FinWait1 uint64
400-
//Count of TCP connections in state "Fin_Wait2"
400+
// Count of TCP connections in state "Fin_Wait2"
401401
FinWait2 uint64
402-
//Count of TCP connections in state "Time_Wait
402+
// Count of TCP connections in state "Time_Wait
403403
TimeWait uint64
404-
//Count of TCP connections in state "Close"
404+
// Count of TCP connections in state "Close"
405405
Close uint64
406-
//Count of TCP connections in state "Close_Wait"
406+
// Count of TCP connections in state "Close_Wait"
407407
CloseWait uint64
408-
//Count of TCP connections in state "Listen_Ack"
408+
// Count of TCP connections in state "Listen_Ack"
409409
LastAck uint64
410-
//Count of TCP connections in state "Listen"
410+
// Count of TCP connections in state "Listen"
411411
Listen uint64
412-
//Count of TCP connections in state "Closing"
412+
// Count of TCP connections in state "Closing"
413413
Closing uint64
414414
}
415415

@@ -511,7 +511,7 @@ type ContainerStats struct {
511511
// Task load stats
512512
TaskStats LoadStats `json:"task_stats,omitempty"`
513513

514-
//Custom metrics from all collectors
514+
// Custom metrics from all collectors
515515
CustomMetrics map[string][]MetricVal `json:"custom_metrics,omitempty"`
516516
}
517517

storage/influxdb/influxdb_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func runStorageTest(f func(test.TestStorageDriver, *testing.T), t *testing.T, bu
9090
username := "root"
9191
password := "root"
9292
hostname := "localhost:8086"
93-
//percentilesDuration := 10 * time.Minute
93+
// percentilesDuration := 10 * time.Minute
9494

9595
config := influxdb.Config{
9696
URL: url.URL{Scheme: "http", Host: hostname},
@@ -108,7 +108,7 @@ func runStorageTest(f func(test.TestStorageDriver, *testing.T), t *testing.T, bu
108108
}
109109

110110
// Delete all data by the end of the call.
111-
//defer client.Query(influxdb.Query{Command: fmt.Sprintf("drop database \"%v\"", database)})
111+
// defer client.Query(influxdb.Query{Command: fmt.Sprintf("drop database \"%v\"", database)})
112112

113113
driver, err := newStorage(machineName,
114114
table,

0 commit comments

Comments
 (0)