|
1 | | -//Provides instruments to read and cache Node Metrics from the custom metrics API. |
| 1 | +//Package metrics instruments to read and cache Node Metrics from the custom metrics API. |
2 | 2 | package metrics |
3 | 3 |
|
4 | 4 | import ( |
@@ -31,24 +31,24 @@ type NodeMetric struct { |
31 | 31 | //NodeMetricsInfo holds a map of metric information related to a single named metric. The key for the map is the name of the node. |
32 | 32 | type NodeMetricsInfo map[string]NodeMetric |
33 | 33 |
|
34 | | -//customMetrics client embeds a client for the custom Metrics API |
35 | | -type customMetricsClient struct { |
| 34 | +//CustomMetricsClient embeds a client for the custom Metrics API |
| 35 | +type CustomMetricsClient struct { |
36 | 36 | customclient.CustomMetricsClient |
37 | 37 | } |
38 | 38 |
|
39 | 39 | //NewClient creates a new Metrics Client including discovering and mapping the available APIs, and pulling the API version. |
40 | | -func NewClient(config *restclient.Config) customMetricsClient { |
| 40 | +func NewClient(config *restclient.Config) CustomMetricsClient { |
41 | 41 | discoveryClient := discovery.NewDiscoveryClientForConfigOrDie(config) |
42 | 42 | cachedDiscoveryClient := cacheddiscovery.NewMemCacheClient(discoveryClient) |
43 | 43 | restMapper := restmapper.NewDeferredDiscoveryRESTMapper(cachedDiscoveryClient) |
44 | 44 | restMapper.Reset() |
45 | 45 | apiVersionsGetter := customclient.NewAvailableAPIsGetter(discoveryClient) |
46 | | - metricsClient := customMetricsClient{customclient.NewForConfig(config, restMapper, apiVersionsGetter)} |
| 46 | + metricsClient := CustomMetricsClient{customclient.NewForConfig(config, restMapper, apiVersionsGetter)} |
47 | 47 | return metricsClient |
48 | 48 | } |
49 | 49 |
|
50 | 50 | //GetNodeMetric gets the given metric, time Window for Metric and timestamp for each node in the cluster. |
51 | | -func (c customMetricsClient) GetNodeMetric(metricName string) (NodeMetricsInfo, error) { |
| 51 | +func (c CustomMetricsClient) GetNodeMetric(metricName string) (NodeMetricsInfo, error) { |
52 | 52 | metrics, err := c.RootScopedMetrics().GetForObjects(schema.GroupKind{Kind: "Node"}, labels.NewSelector(), metricName, labels.NewSelector()) |
53 | 53 | if err != nil { |
54 | 54 | return nil, errors.New("unable to fetch metrics from custom metrics API: " + err.Error()) |
|
0 commit comments