Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update telemetry data types from int to int64 #5185

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions internal/telemetry/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (

// NodeCount returns the total number of nodes in the cluster.
// It returns an error if the underlying k8s API client errors.
func (c *Collector) NodeCount(ctx context.Context) (int, error) {
func (c *Collector) NodeCount(ctx context.Context) (int64, error) {
nodes, err := c.Config.K8sClientReader.CoreV1().Nodes().List(ctx, metaV1.ListOptions{})
if err != nil {
return 0, err
}
return len(nodes.Items), nil
return int64(len(nodes.Items)), nil
}

// ClusterID returns the UID of the kube-system namespace representing cluster id.
Expand Down
4 changes: 2 additions & 2 deletions internal/telemetry/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestNodeCountInAClusterWithThreeNodes(t *testing.T) {
if err != nil {
t.Fatal(err)
}
want := 3
var want int64 = 3
if want != got {
t.Errorf("want %v, got %v", want, got)
}
Expand All @@ -33,7 +33,7 @@ func TestNodeCountInAClusterWithOneNode(t *testing.T) {
if err != nil {
t.Fatal(err)
}
want := 1
var want int64 = 1
if want != got {
t.Errorf("want %v, got %v", want, got)
}
Expand Down
18 changes: 7 additions & 11 deletions internal/telemetry/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,25 +108,21 @@ func (c *Collector) BuildReport(ctx context.Context) (Data, error) {
var err error

if c.Config.Configurator != nil {
d.NICResourceCounts.VirtualServers, d.NICResourceCounts.VirtualServerRoutes = c.Config.Configurator.GetVirtualServerCounts()
d.NICResourceCounts.TransportServers = c.Config.Configurator.GetTransportServerCounts()
vsCount, vsrCount := c.Config.Configurator.GetVirtualServerCounts()
d.VirtualServers, d.VirtualServerRoutes = int64(vsCount), int64(vsrCount)
d.TransportServers = int64(c.Config.Configurator.GetTransportServerCounts())
}
nc, err := c.NodeCount(ctx)
if err != nil {

if d.NodeCount, err = c.NodeCount(ctx); err != nil {
glog.Errorf("Error collecting telemetry data: Nodes: %v", err)
}
d.NodeCount = nc

cID, err := c.ClusterID(ctx)
if err != nil {
if d.ClusterID, err = c.ClusterID(ctx); err != nil {
glog.Errorf("Error collecting telemetry data: ClusterID: %v", err)
}
d.ClusterID = cID

k8s, err := c.K8sVersion()
if err != nil {
if d.K8sVersion, err = c.K8sVersion(); err != nil {
glog.Errorf("Error collecting telemetry data: K8s Version: %v", err)
}
d.K8sVersion = k8s
return d, err
}
18 changes: 9 additions & 9 deletions internal/telemetry/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ func (e *StdoutExporter) Export(_ context.Context, data Data) error {

// Data holds collected telemetry data.
type Data struct {
ProjectMeta ProjectMeta
NICResourceCounts NICResourceCounts
NodeCount int
ClusterID string
K8sVersion string
Arch string
ProjectMeta
NICResourceCounts
NodeCount int64
ClusterID string
K8sVersion string
Arch string
}

// ProjectMeta holds metadata for the project.
Expand All @@ -43,9 +43,9 @@ type ProjectMeta struct {

// NICResourceCounts holds a count of NIC specific resource.
type NICResourceCounts struct {
VirtualServers int
VirtualServerRoutes int
TransportServers int
VirtualServers int64
VirtualServerRoutes int64
TransportServers int64
}

// Attributes is a placeholder function.
Expand Down