Skip to content

Commit

Permalink
Monitoring: fix error on Stackdriver exporter (#1479)
Browse files Browse the repository at this point in the history
Zero value cannot be used as the only value for view.Distribution().
  • Loading branch information
aLekSer authored Apr 25, 2020
1 parent 0ad41f9 commit e7b92d6
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions pkg/metrics/kubernetes_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ var (
)

func init() {
distributionSeconds := []float64{0, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2, 3}
distributionNumbers := []float64{0, 10, 50, 100, 150, 250, 300}

runtime.Must(view.Register(&view.View{
Name: "k8s_client_http_request_total",
Expand All @@ -66,7 +68,7 @@ func init() {
Name: "k8s_client_http_request_duration_seconds",
Measure: httpRequestLatencyStats,
Description: "The distribution of HTTP requests latencies to the Kubernetes API by status code",
Aggregation: view.Distribution(0, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2, 3),
Aggregation: view.Distribution(distributionSeconds...),
TagKeys: []tag.Key{keyVerb, keyEndpoint},
}))

Expand All @@ -81,14 +83,14 @@ func init() {
Name: "k8s_client_cache_list_duration_seconds",
Measure: cacheListLatencyStats,
Description: "Duration of a Kubernetes list API call in seconds",
Aggregation: view.Distribution(0, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2, 3),
Aggregation: view.Distribution(distributionSeconds...),
}))

runtime.Must(view.Register(&view.View{
Name: "k8s_client_cache_list_items",
Measure: cacheListItemCountStats,
Description: "Count of items in a list from the Kubernetes API.",
Aggregation: view.Distribution(0),
Aggregation: view.Distribution(distributionNumbers...),
}))

runtime.Must(view.Register(&view.View{
Expand All @@ -109,14 +111,14 @@ func init() {
Name: "k8s_client_cache_watch_duration_seconds",
Measure: cacheWatchesLatencyStats,
Description: "Duration of watches on the Kubernetes API.",
Aggregation: view.Distribution(0),
Aggregation: view.Distribution(distributionSeconds...),
}))

runtime.Must(view.Register(&view.View{
Name: "k8s_client_cache_watch_events",
Measure: cacheItemsInWatchesCountStats,
Description: "Number of items in watches on the Kubernetes API.",
Aggregation: view.Distribution(0),
Aggregation: view.Distribution(distributionNumbers...),
}))

runtime.Must(view.Register(&view.View{
Expand Down Expand Up @@ -146,15 +148,15 @@ func init() {
Name: "k8s_client_workqueue_latency_seconds",
Measure: workQueueLatencyStats,
Description: "How long an item stays in the work queue.",
Aggregation: view.Distribution(0),
Aggregation: view.Distribution(distributionSeconds...),
TagKeys: []tag.Key{keyQueueName},
}))

runtime.Must(view.Register(&view.View{
Name: "k8s_client_workqueue_work_duration_seconds",
Measure: workQueueWorkDurationStats,
Description: "How long processing an item from the work queue takes.",
Aggregation: view.Distribution(0),
Aggregation: view.Distribution(distributionSeconds...),
TagKeys: []tag.Key{keyQueueName},
}))

Expand Down

0 comments on commit e7b92d6

Please sign in to comment.