Skip to content

Commit d10b842

Browse files
authored
Fix the readability of isUsefulLabel (#2980)
Remove the intermediate return variable and make use of the multiple values in case.
1 parent 6661f03 commit d10b842

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

receiver/prometheusreceiver/internal/metricsbuilder.go

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -159,22 +159,16 @@ func (b *metricBuilder) Build() ([]*metricspb.Metric, int, int, error) {
159159
// TODO: move the following helper functions to a proper place, as they are not called directly in this go file
160160

161161
func isUsefulLabel(mType metricspb.MetricDescriptor_Type, labelKey string) bool {
162-
result := false
163162
switch labelKey {
164-
case model.MetricNameLabel:
165-
case model.InstanceLabel:
166-
case model.SchemeLabel:
167-
case model.MetricsPathLabel:
168-
case model.JobLabel:
163+
case model.MetricNameLabel, model.InstanceLabel, model.SchemeLabel, model.MetricsPathLabel, model.JobLabel:
164+
return false
169165
case model.BucketLabel:
170-
result = mType != metricspb.MetricDescriptor_GAUGE_DISTRIBUTION &&
166+
return mType != metricspb.MetricDescriptor_GAUGE_DISTRIBUTION &&
171167
mType != metricspb.MetricDescriptor_CUMULATIVE_DISTRIBUTION
172168
case model.QuantileLabel:
173-
result = mType != metricspb.MetricDescriptor_SUMMARY
174-
default:
175-
result = true
169+
return mType != metricspb.MetricDescriptor_SUMMARY
176170
}
177-
return result
171+
return true
178172
}
179173

180174
// dpgSignature is used to create a key for data complexValue belong to a same group of a metric family

0 commit comments

Comments
 (0)