Skip to content

Commit

Permalink
Get rid of MetricName type (#4479)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelSnowden committed Jun 11, 2023
1 parent eeee3a0 commit eeec6e0
Showing 1 changed file with 8 additions and 21 deletions.
29 changes: 8 additions & 21 deletions common/metrics/defs.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,12 @@ package metrics

// types used/defined by the package
type (
// MetricName is the name of the metric
MetricName string

MetricUnit string

// metricDefinition contains the definition for a metric
metricDefinition struct {
metricName MetricName // metric name
unit MetricUnit
name string
unit MetricUnit
}
)

Expand All @@ -47,40 +44,30 @@ const (
Bytes = "By"
)

// Empty returns true if the metricName is an empty string
func (mn MetricName) Empty() bool {
return mn == ""
}

// String returns string representation of this metric name
func (mn MetricName) String() string {
return string(mn)
}

func (md metricDefinition) GetMetricName() string {
return md.metricName.String()
return md.name
}

func (md metricDefinition) GetMetricUnit() MetricUnit {
return md.unit
}

func NewTimerDef(name string) metricDefinition {
return metricDefinition{metricName: MetricName(name), unit: Milliseconds}
return metricDefinition{name: name, unit: Milliseconds}
}

func NewBytesHistogramDef(name string) metricDefinition {
return metricDefinition{metricName: MetricName(name), unit: Bytes}
return metricDefinition{name: name, unit: Bytes}
}

func NewDimensionlessHistogramDef(name string) metricDefinition {
return metricDefinition{metricName: MetricName(name), unit: Dimensionless}
return metricDefinition{name: name, unit: Dimensionless}
}

func NewCounterDef(name string) metricDefinition {
return metricDefinition{metricName: MetricName(name)}
return metricDefinition{name: name}
}

func NewGaugeDef(name string) metricDefinition {
return metricDefinition{metricName: MetricName(name)}
return metricDefinition{name: name}
}

0 comments on commit eeec6e0

Please sign in to comment.