Skip to content

Commit

Permalink
Move metric constants to their own file
Browse files Browse the repository at this point in the history
  • Loading branch information
s-fairchild committed Jun 25, 2024
1 parent 27a3684 commit 0a54cd5
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 70 deletions.
70 changes: 0 additions & 70 deletions pkg/backend/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,76 +14,6 @@ import (
utillog "github.com/Azure/ARO-RP/pkg/util/log"
)

const (
metricPackage = "backend.openshiftcluster"
enabled = "Enabled"
disabled = "Disabled"
custom = "Custom"
defaultSet = "Default"
unknown = "unknown"
empty = "empty"
managed = "managed"

encryptionAtHostMetricName = "encryptionathost"
diskSizeMetricName = "disksize"
vmSizeMetricName = "vmsize"
countMetricName = "count"

workerProfileMetricName = "workprofile"
workerVmSizeMetricName = workerProfileMetricName + "." + vmSizeMetricName
workerVmDiskSizeMetricName = workerProfileMetricName + "." + diskSizeMetricName
workerEncryptionAtHostMetricName = workerProfileMetricName + "." + encryptionAtHostMetricName
workerProfileCountMetricName = workerProfileMetricName + "." + countMetricName

masterProfileMetricName = "masterprofile"
masterEncryptionAtHostMetricName = masterProfileMetricName + "." + encryptionAtHostMetricName
masterProfileEncryptionSetIdMetricName = masterProfileMetricName + "." + "diskencryptionsetid"
masterProfileVmSizeMetricName = masterProfileMetricName + "." + vmSizeMetricName

fipsMetricName = "fips"
clusterIdentityMetricName = "clusteridentity"
clusterIdentityManagedIdMetricName = managed + "id"
clusterIdentityServicePrincipalMetricName = "serviceprincipal"
pullSecretMetricName = "pullsecret"

ingressProfileMetricName = "ingressprofile"
networkProfileMetricName = "networkprofile"
networkProfileOutboundTypeMetricName = networkProfileMetricName + "." + "outboundtype"
networkProfileManagedOutboundIpsMetricName = networkProfileMetricName + "." + "managedoutboundips"
networkProfilePreConfiguredNSGMetricName = networkProfileMetricName + "." + "preconfigurednsg"
podCidrMetricName = networkProfileMetricName + "." + "podcidr"
podCidrDefaultValue = networkProfileMetricName + "." + "10.128.0.0/14"
serviceCidrMetricName = "servicecidr"
serviceCidrDefaultValue = "172.30.0.0/16"

featureProfileMetricName = "featureprofile"
featureProfileGatewayEnabledMetricName = featureProfileMetricName + "." + "gatewayenabled"

clusterProfileMetricName = "clusterprofile"
clusterProfileDomainMetricName = clusterProfileMetricName + "." + "domain"

tagsMetricName = "tags"
operatorFlagsMetricName = "operatorflags"

asyncOperationsIdMetricName = "async_operationsid"
rpVersionMetricName = "rpversion"
ocpVersionMetricName = "ocpversion"
clusterNameMetricName = "clustername"
resourecGroupMetricName = "resourcegroup"
locationMetricName = "location"
resourceIdMetricName = "resourceid"
subscriptionIdMetricName = "subscriptionid"

correlationDataMetricName = "correlationdata"
correlationDataRequestIdMetricName = correlationDataMetricName + "." + "requestid"
correlationDataClientRequestIdMetricName = correlationDataMetricName + "." + "client_requestid"
correlationDataIdMetricName = correlationDataMetricName + "." + "correlationid"

operationTypeMetricName = "operationtype"
provisioningStateMetricName = "provisioningstate"
resultTypeMetricName = "resulttype"
)

func (ocb *openShiftClusterBackend) emitMetrics(log *logrus.Entry, doc *api.OpenShiftClusterDocument, operationType, provisioningState api.ProvisioningState, backendErr error) error {
dimensions := map[string]string{
operationTypeMetricName: operationType.String(),
Expand Down
75 changes: 75 additions & 0 deletions pkg/backend/metrics_const.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package backend

// Copyright (c) Microsoft Corporation.
// Licensed under the Apache License 2.0.

const (
metricPackage = "backend.openshiftcluster"
metricValue int64 = 1
enabled = "Enabled"
disabled = "Disabled"
custom = "Custom"
defaultSet = "Default"
unknown = "unknown"
empty = "empty"
managed = "managed"

encryptionAtHostMetricName = "encryptionathost"
diskSizeMetricName = "disksize"
vmSizeMetricName = "vmsize"
countMetricName = "count"

workerProfileMetricName = "workprofile"
workerVmSizeMetricName = workerProfileMetricName + "." + vmSizeMetricName
workerVmDiskSizeMetricName = workerProfileMetricName + "." + diskSizeMetricName
workerEncryptionAtHostMetricName = workerProfileMetricName + "." + encryptionAtHostMetricName
workerProfileCountMetricName = workerProfileMetricName + "." + countMetricName

masterProfileMetricName = "masterprofile"
masterEncryptionAtHostMetricName = masterProfileMetricName + "." + encryptionAtHostMetricName
masterProfileEncryptionSetIdMetricName = masterProfileMetricName + "." + "diskencryptionsetid"
masterProfileVmSizeMetricName = masterProfileMetricName + "." + vmSizeMetricName

fipsMetricName = "fips"
clusterIdentityMetricName = "clusteridentity"
clusterIdentityManagedIdMetricName = managed + "id"
clusterIdentityServicePrincipalMetricName = "serviceprincipal"
pullSecretMetricName = "pullsecret"

ingressProfileMetricName = "ingressprofile"
networkProfileMetricName = "networkprofile"
networkProfileOutboundTypeMetricName = networkProfileMetricName + "." + "outboundtype"
networkProfileManagedOutboundIpsMetricName = networkProfileMetricName + "." + "managedoutboundips"
networkProfilePreConfiguredNSGMetricName = networkProfileMetricName + "." + "preconfigurednsg"
podCidrMetricName = networkProfileMetricName + "." + "podcidr"
podCidrDefaultValue = networkProfileMetricName + "." + "10.128.0.0/14"
serviceCidrMetricName = "servicecidr"
serviceCidrDefaultValue = "172.30.0.0/16"

featureProfileMetricName = "featureprofile"
featureProfileGatewayEnabledMetricName = featureProfileMetricName + "." + "gatewayenabled"

clusterProfileMetricName = "clusterprofile"
clusterProfileDomainMetricName = clusterProfileMetricName + "." + "domain"

tagsMetricName = "tags"
operatorFlagsMetricName = "operatorflags"

asyncOperationsIdMetricName = "async_operationsid"
rpVersionMetricName = "rpversion"
ocpVersionMetricName = "ocpversion"
clusterNameMetricName = "clustername"
resourecGroupMetricName = "resourcegroup"
locationMetricName = "location"
resourceIdMetricName = "resourceid"
subscriptionIdMetricName = "subscriptionid"

correlationDataMetricName = "correlationdata"
correlationDataRequestIdMetricName = correlationDataMetricName + "." + "requestid"
correlationDataClientRequestIdMetricName = correlationDataMetricName + "." + "client_requestid"
correlationDataIdMetricName = correlationDataMetricName + "." + "correlationid"

operationTypeMetricName = "operationtype"
provisioningStateMetricName = "provisioningstate"
resultTypeMetricName = "resulttype"
)

0 comments on commit 0a54cd5

Please sign in to comment.