Skip to content

Commit 4450030

Browse files
committed
fix(metrics): retain early nil return with no name
1 parent ab4e4a5 commit 4450030

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

pkg/util/metrics/metric_float64.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,12 @@ type Float64MetricInterface interface {
4444
Record(labelValues map[string]string, value float64) error
4545
}
4646

47-
// NewFloat64Metric creates a new Float64 metric using OpenTelemetry
47+
// NewFloat64Metric creates a new Float64 metric using OpenTelemetry, returns nil when name is empty
4848
func NewFloat64Metric(metricID MetricID, name, description, unit string, aggregation Aggregation, labels []string) (*Float64Metric, error) {
49+
if name == "" {
50+
return nil, nil
51+
}
52+
4953
meter := otelutil.GetGlobalMeter()
5054

5155
otelMetric := &OTelFloat64Metric{

pkg/util/metrics/metric_int64.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,12 @@ type Int64MetricInterface interface {
4444
Record(labelValues map[string]string, value int64) error
4545
}
4646

47-
// NewInt64Metric creates a new Int64 metric using OpenTelemetry
47+
// NewInt64Metric creates a new Int64 metric using OpenTelemetry, returns nil when name is empty
4848
func NewInt64Metric(metricID MetricID, name, description, unit string, aggregation Aggregation, labels []string) (*Int64Metric, error) {
49+
if name == "" {
50+
return nil, nil
51+
}
52+
4953
meter := otelutil.GetGlobalMeter()
5054

5155
otelMetric := &OTelInt64Metric{

0 commit comments

Comments
 (0)