Skip to content

Commit

Permalink
Cleanup comment style: // should be proceded by a space
Browse files Browse the repository at this point in the history
  • Loading branch information
tallclair committed Oct 8, 2016
1 parent 0c6b72d commit afe67fe
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 62 deletions.
20 changes: 10 additions & 10 deletions collector/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,43 +22,43 @@ import (
)

type Config struct {
//the endpoint to hit to scrape metrics
// the endpoint to hit to scrape metrics
Endpoint EndpointConfig `json:"endpoint"`

//holds information about different metrics that can be collected
// holds information about different metrics that can be collected
MetricsConfig []MetricConfig `json:"metrics_config"`
}

// metricConfig holds information extracted from the config file about a metric
type MetricConfig struct {
//the name of the metric
// the name of the metric
Name string `json:"name"`

//enum type for the metric type
// enum type for the metric type
MetricType v1.MetricType `json:"metric_type"`

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

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

//the frequency at which the metric should be collected
// the frequency at which the metric should be collected
PollingFrequency time.Duration `json:"polling_frequency"`

//the regular expression that can be used to extract the metric
// the regular expression that can be used to extract the metric
Regex string `json:"regex"`
}

type Prometheus struct {
//the endpoint to hit to scrape metrics
// the endpoint to hit to scrape metrics
Endpoint EndpointConfig `json:"endpoint"`

//the frequency at which metrics should be collected
// the frequency at which metrics should be collected
PollingFrequency time.Duration `json:"polling_frequency"`

//holds names of different metrics that can be collected
// holds names of different metrics that can be collected
MetricsConfig []string `json:"metrics_config"`
}

Expand Down
18 changes: 9 additions & 9 deletions collector/generic_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,32 @@ import (
)

type GenericCollector struct {
//name of the collector
// name of the collector
name string

//holds information extracted from the config file for a collector
// holds information extracted from the config file for a collector
configFile Config

//holds information necessary to extract metrics
// holds information necessary to extract metrics
info *collectorInfo

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

type collectorInfo struct {
//minimum polling frequency among all metrics
// minimum polling frequency among all metrics
minPollingFrequency time.Duration

//regular expresssions for all metrics
// regular expresssions for all metrics
regexps []*regexp.Regexp

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

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

configInJSON.Endpoint.configure(containerHandler)

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

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

//Returns name of the collector
// Returns name of the collector
func (collector *GenericCollector) Name() string {
return collector.name
}
Expand All @@ -132,7 +132,7 @@ func (collector *GenericCollector) GetSpec() []v1.MetricSpec {
return specs
}

//Returns collected metrics and the next collection time of the collector
// Returns collected metrics and the next collection time of the collector
func (collector *GenericCollector) Collect(metrics map[string][]v1.MetricVal) (time.Time, map[string][]v1.MetricVal, error) {
currentTime := time.Now()
nextCollectionTime := currentTime.Add(time.Duration(collector.info.minPollingFrequency))
Expand Down
16 changes: 8 additions & 8 deletions collector/generic_collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestEmptyConfig(t *testing.T) {
}
`

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

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

//Syntax error: Missed '"' after activeConnections
// Syntax error: Missed '"' after activeConnections
invalid := `
{
"endpoint" : "http://localhost:8000/nginx_status",
Expand All @@ -71,7 +71,7 @@ func TestConfigWithErrors(t *testing.T) {
}
`

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

//Error: Missed operand for '+' in activeConnections regex
// Error: Missed operand for '+' in activeConnections regex
invalid := `
{
"endpoint" : "host:port/nginx_status",
Expand All @@ -109,7 +109,7 @@ func TestConfigWithRegexErrors(t *testing.T) {
}
`

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

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

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

Expand Down Expand Up @@ -157,7 +157,7 @@ func TestEndpointConfig(t *testing.T) {
func TestMetricCollection(t *testing.T) {
assert := assert.New(t)

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

Expand Down Expand Up @@ -193,7 +193,7 @@ func TestMetricCollection(t *testing.T) {
func TestMetricCollectionLimit(t *testing.T) {
assert := assert.New(t)

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

Expand Down
14 changes: 7 additions & 7 deletions collector/prometheus_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ import (
)

type PrometheusCollector struct {
//name of the collector
// name of the collector
name string

//rate at which metrics are collected
// rate at which metrics are collected
pollingFrequency time.Duration

//holds information extracted from the config file for a collector
// holds information extracted from the config file for a collector
configFile Prometheus

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

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

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

//Returns name of the collector
// Returns name of the collector
func (collector *PrometheusCollector) Name() string {
return collector.name
}
Expand Down Expand Up @@ -201,7 +201,7 @@ func prometheusLabelSetToCadvisorLabel(promLabels model.Metric) string {
return string(b.Bytes())
}

//Returns collected metrics and the next collection time of the collector
// Returns collected metrics and the next collection time of the collector
func (collector *PrometheusCollector) Collect(metrics map[string][]v1.MetricVal) (time.Time, map[string][]v1.MetricVal, error) {
currentTime := time.Now()
nextCollectionTime := currentTime.Add(time.Duration(collector.pollingFrequency))
Expand Down
10 changes: 5 additions & 5 deletions collector/prometheus_collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
func TestPrometheus(t *testing.T) {
assert := assert.New(t)

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

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

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

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

//Create a prometheus collector using the config file 'sample_config_prometheus_filtered.json'
// Create a prometheus collector using the config file 'sample_config_prometheus_filtered.json'
configFile, err := ioutil.ReadFile("config/sample_config_prometheus_filtered.json")
containerHandler := containertest.NewMockContainerHandler("mockContainer")
_, err = NewPrometheusCollector("Prometheus", configFile, 1, containerHandler, http.DefaultClient)
Expand Down
2 changes: 1 addition & 1 deletion container/rkt/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func newRktContainerHandler(name string, rktClient rktapi.PublicAPIClient, rktPa
return nil, fmt.Errorf("this should be impossible!, new handler failing, but factory allowed, name = %s", name)
}

//rktnetes uses containerID: rkt://fff40827-b994-4e3a-8f88-6427c2c8a5ac:nginx
// rktnetes uses containerID: rkt://fff40827-b994-4e3a-8f88-6427c2c8a5ac:nginx
if parsed.Container == "" {
isPod = true
aliases = append(aliases, "rkt://"+parsed.Pod)
Expand Down
24 changes: 12 additions & 12 deletions info/v1/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,27 +389,27 @@ type NetworkStats struct {
}

type TcpStat struct {
//Count of TCP connections in state "Established"
// Count of TCP connections in state "Established"
Established uint64
//Count of TCP connections in state "Syn_Sent"
// Count of TCP connections in state "Syn_Sent"
SynSent uint64
//Count of TCP connections in state "Syn_Recv"
// Count of TCP connections in state "Syn_Recv"
SynRecv uint64
//Count of TCP connections in state "Fin_Wait1"
// Count of TCP connections in state "Fin_Wait1"
FinWait1 uint64
//Count of TCP connections in state "Fin_Wait2"
// Count of TCP connections in state "Fin_Wait2"
FinWait2 uint64
//Count of TCP connections in state "Time_Wait
// Count of TCP connections in state "Time_Wait
TimeWait uint64
//Count of TCP connections in state "Close"
// Count of TCP connections in state "Close"
Close uint64
//Count of TCP connections in state "Close_Wait"
// Count of TCP connections in state "Close_Wait"
CloseWait uint64
//Count of TCP connections in state "Listen_Ack"
// Count of TCP connections in state "Listen_Ack"
LastAck uint64
//Count of TCP connections in state "Listen"
// Count of TCP connections in state "Listen"
Listen uint64
//Count of TCP connections in state "Closing"
// Count of TCP connections in state "Closing"
Closing uint64
}

Expand Down Expand Up @@ -511,7 +511,7 @@ type ContainerStats struct {
// Task load stats
TaskStats LoadStats `json:"task_stats,omitempty"`

//Custom metrics from all collectors
// Custom metrics from all collectors
CustomMetrics map[string][]MetricVal `json:"custom_metrics,omitempty"`
}

Expand Down
4 changes: 2 additions & 2 deletions storage/influxdb/influxdb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func runStorageTest(f func(test.TestStorageDriver, *testing.T), t *testing.T, bu
username := "root"
password := "root"
hostname := "localhost:8086"
//percentilesDuration := 10 * time.Minute
// percentilesDuration := 10 * time.Minute

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

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

driver, err := newStorage(machineName,
table,
Expand Down
Loading

0 comments on commit afe67fe

Please sign in to comment.