@@ -90,9 +90,9 @@ func registerCinderMetrics() {
90
90
prometheus .MustRegister (cinderVolumeAttachedAt )
91
91
}
92
92
93
- // ScrapeCinderMetrics makes the list request to the blockstorage api and passes
94
- // the result to a scrape function.
95
- func ScrapeCinderMetrics (client * gophercloud.ServiceClient , clientset * kubernetes.Clientset , tenantID string ) error {
93
+ // PublishCinderMetrics makes the list request to the blockstorage api and passes
94
+ // the result to a publish function.
95
+ func PublishCinderMetrics (client * gophercloud.ServiceClient , clientset * kubernetes.Clientset , tenantID string ) error {
96
96
// get the cinder pvs to add metadata
97
97
pvs , err := getPVsByCinderID (clientset )
98
98
if err != nil {
@@ -106,31 +106,31 @@ func ScrapeCinderMetrics(client *gophercloud.ServiceClient, clientset *kubernete
106
106
cinderVolumeSize .Reset ()
107
107
cinderVolumeAttachedAt .Reset ()
108
108
109
- // get all volumes and scrape them
109
+ // get all volumes and publish them
110
110
mc := newOpenStackMetric ("volume" , "list" )
111
111
pager := volumes .List (client , volumes.ListOpts {})
112
112
err = pager .EachPage (func (page pagination.Page ) (bool , error ) {
113
- return scrapeVolumesPage (page , pvs )
113
+ return publishVolumesPage (page , pvs )
114
114
})
115
115
if mc .Observe (err ) != nil {
116
- // only warn, maybe the next scrape will work.
117
- klog .Warningf ("Unable to scrape volumes: %v" , err )
116
+ // only warn, maybe the next list will work.
117
+ klog .Warningf ("Unable to list volumes: %v" , err )
118
118
return err
119
119
}
120
120
121
121
mc = newOpenStackMetric ("volume_quotasets_usage" , "get" )
122
122
q , err := quotasets .GetUsage (client , tenantID ).Extract ()
123
123
if mc .Observe (err ) != nil {
124
- // only warn, maybe the next scrape will work.
125
- klog .Warningf ("Unable to scrape quotas: %v" , err )
124
+ // only warn, maybe the next get will work.
125
+ klog .Warningf ("Unable to get quotas: %v" , err )
126
126
return err
127
127
}
128
- scrapeCinderQuotas (q )
128
+ publishCinderQuotas (q )
129
129
return nil
130
130
}
131
131
132
- // scrapeCinderQuotas scrapes all cinder related quotas
133
- func scrapeCinderQuotas (q quotasets.QuotaUsageSet ) {
132
+ // publishCinderQuotas publishes all cinder related quotas
133
+ func publishCinderQuotas (q quotasets.QuotaUsageSet ) {
134
134
cinderQuotaVolumes .WithLabelValues ("in-use" ).Set (float64 (q .Volumes .InUse ))
135
135
cinderQuotaVolumes .WithLabelValues ("reserved" ).Set (float64 (q .Volumes .Reserved ))
136
136
cinderQuotaVolumes .WithLabelValues ("limit" ).Set (float64 (q .Volumes .Limit ))
@@ -142,25 +142,25 @@ func scrapeCinderQuotas(q quotasets.QuotaUsageSet) {
142
142
cinderQuotaVolumesGigabyte .WithLabelValues ("allocated" ).Set (float64 (q .Gigabytes .Allocated ))
143
143
}
144
144
145
- // scrapeVolumesPage iterates over a page, the result of a list request
146
- func scrapeVolumesPage (page pagination.Page , pvs map [string ]corev1.PersistentVolume ) (bool , error ) {
145
+ // publishVolumesPage iterates over a page, the result of a list request
146
+ func publishVolumesPage (page pagination.Page , pvs map [string ]corev1.PersistentVolume ) (bool , error ) {
147
147
vList , err := volumes .ExtractVolumes (page )
148
148
if err != nil {
149
149
return false , err
150
150
}
151
151
152
152
for _ , v := range vList {
153
153
if pv , ok := pvs [v .ID ]; ok {
154
- scrapeVolumeMetrics (v , & pv )
154
+ publishVolumeMetrics (v , & pv )
155
155
} else {
156
- scrapeVolumeMetrics (v , nil )
156
+ publishVolumeMetrics (v , nil )
157
157
}
158
158
}
159
159
return true , nil
160
160
}
161
161
162
- // scrapeVolumeMetrics extracts data from a volume and exposes the metrics via prometheus
163
- func scrapeVolumeMetrics (v volumes.Volume , pv * corev1.PersistentVolume ) {
162
+ // publishVolumeMetrics extracts data from a volume and exposes the metrics via prometheus
163
+ func publishVolumeMetrics (v volumes.Volume , pv * corev1.PersistentVolume ) {
164
164
labels := []string {v .ID , v .Description , v .Name , v .Status , v .AvailabilityZone , v .VolumeType }
165
165
166
166
k8sMetadata := extractK8sMetadata (pv )
0 commit comments