Skip to content

Commit

Permalink
Move remaining metrics gathering into it's own function
Browse files Browse the repository at this point in the history
This allows for easier unit testing to be done, without having to setup a metrics vm.
  • Loading branch information
s-fairchild committed Jun 14, 2024
1 parent 8a62f67 commit 5f4953c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 deletions.
2 changes: 1 addition & 1 deletion pkg/cluster/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ func (m *manager) Install(ctx context.Context) error {
steps.Condition(m.ingressControllerReady, 30*time.Minute, true),
steps.Action(m.configureDefaultStorageClass),
steps.Action(m.finishInstallation),
steps.Action(m.emitFeatures),
steps.Action(m.gatherEmitInstallMetrics),
},
}

Expand Down
44 changes: 25 additions & 19 deletions pkg/cluster/install_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,10 @@ const (
defaultSet = "Default"
)

func (m *manager) emitFeatures(ctx context.Context) error {
dimensions := map[string]string{
"resourceid": m.doc.ResourceID,
"subscriptionid": m.env.SubscriptionID(),
"location": m.doc.OpenShiftCluster.Location,
"resourcegroup": m.doc.OpenShiftCluster.Properties.ClusterProfile.ResourceGroupID,
"name": m.doc.OpenShiftCluster.Name,
"ocpversion": m.doc.OpenShiftCluster.Properties.ClusterProfile.Version,
"workercount": strconv.FormatInt(int64(len(m.doc.OpenShiftCluster.Properties.WorkerProfiles)), 10),
}
func (m *manager) gatherEmitInstallMetrics(ctx context.Context) error {
dimensions := map[string]string{}

for flag, feature := range m.doc.OpenShiftCluster.Properties.OperatorFlags {
dimensions[flag] = feature
}

if m.doc.OpenShiftCluster.Tags != nil {
dimensions["tags"] = enabled
} else {
dimensions["tags"] = disabled
}
m.gatherMiscMetrics(dimensions)

err := m.gatherAuthMetrics(dimensions)
if err != nil {
Expand All @@ -61,6 +45,28 @@ func (m *manager) emitFeatures(ctx context.Context) error {
return nil
}

func (m *manager) gatherMiscMetrics(dimensions map[string]string) {
dimensions["resourceid"] = m.doc.ResourceID
dimensions["subscriptionid"] = m.env.SubscriptionID()
dimensions["tenantid"] = m.env.TenantID()
dimensions["location"] = m.doc.OpenShiftCluster.Location
dimensions["resourcegroup"] = m.doc.OpenShiftCluster.Properties.ClusterProfile.ResourceGroupID
dimensions["name"] = m.doc.OpenShiftCluster.Name
dimensions["ocpversion"] = m.doc.OpenShiftCluster.Properties.ClusterProfile.Version
dimensions["workercount"] = strconv.FormatInt(int64(len(m.doc.OpenShiftCluster.Properties.WorkerProfiles)), 10)
dimensions["rpversion"] = m.doc.OpenShiftCluster.Properties.ProvisionedBy

for flag, feature := range m.doc.OpenShiftCluster.Properties.OperatorFlags {
dimensions[flag] = feature
}

if m.doc.OpenShiftCluster.Tags != nil {
dimensions["tags"] = enabled
} else {
dimensions["tags"] = disabled
}
}

func (m *manager) gatherNodeMetrics(dimensions map[string]string) error {
if m.doc.OpenShiftCluster.Properties.MasterProfile.DiskEncryptionSetID != "" {
dimensions["masterprofile.diskencryptionsetid"] = enabled
Expand Down

0 comments on commit 5f4953c

Please sign in to comment.