-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Container level metrics for CPU and memory resources. (amazon-con…
…tributing#150) * Add container level CPU and memory metrics collection 1. Add metric collection at container level 2. Refactor existing kubelet code to make it unit testable. 3. Add units for kubelet to test pod, node and container level metric collection. * Refactor: rename port -> hostPort and summaryProvider -> kubeletSummaryProvider * Refactor: Change naming in kubelet 2. Remove pas by reference to extractors * Refactored: address naming inconsistencies * Refactor: remove extra GetClient * Fix merge conflict
- Loading branch information
1 parent
dfc7c15
commit fa622c9
Showing
6 changed files
with
349 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 0 additions & 94 deletions
94
receiver/awscontainerinsightreceiver/internal/k8swindows/kubelet.go
This file was deleted.
Oops, something went wrong.
52 changes: 52 additions & 0 deletions
52
receiver/awscontainerinsightreceiver/internal/k8swindows/kubelet/client.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
//go:build windows | ||
// +build windows | ||
|
||
package kubelet | ||
|
||
import ( | ||
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscontainerinsightreceiver/internal/stores/kubeletutil" | ||
"go.uber.org/zap" | ||
stats "k8s.io/kubelet/pkg/apis/stats/v1alpha1" | ||
) | ||
|
||
// KubeletProvider Represents interface to kubelet. | ||
type KubeletProvider interface { | ||
GetSummary() (*stats.Summary, error) | ||
} | ||
|
||
type kubeletProvider struct { | ||
logger *zap.Logger | ||
hostIP string | ||
hostPort string | ||
client *kubeletutil.KubeletClient | ||
} | ||
|
||
// getClient Returns singleton kubelet client. | ||
func (kp *kubeletProvider) getClient() (*kubeletutil.KubeletClient, error) { | ||
if kp.client != nil { | ||
return kp.client, nil | ||
} | ||
kclient, err := kubeletutil.NewKubeletClient(kp.hostIP, kp.hostPort, kp.logger) | ||
if err != nil { | ||
kp.logger.Error("failed to initialize new kubelet client, ", zap.Error(err)) | ||
return nil, err | ||
} | ||
kp.client = kclient | ||
return kclient, nil | ||
} | ||
|
||
// GetSummary Get Summary from kubelet API. | ||
func (kp *kubeletProvider) GetSummary() (*stats.Summary, error) { | ||
kclient, err := kp.getClient() | ||
if err != nil { | ||
kp.logger.Error("failed to get kubelet client, ", zap.Error(err)) | ||
return nil, err | ||
} | ||
|
||
summary, err := kclient.Summary(kp.logger) | ||
if err != nil { | ||
kp.logger.Error("failure from kubelet on getting summary, ", zap.Error(err)) | ||
return nil, err | ||
} | ||
return summary, nil | ||
} |
Oops, something went wrong.