diff --git a/sdk/export/metric/aggregator/aggregator_test.go b/sdk/export/metric/aggregator/aggregator_test.go index 19381302fa0c..8d6af08c43c7 100644 --- a/sdk/export/metric/aggregator/aggregator_test.go +++ b/sdk/export/metric/aggregator/aggregator_test.go @@ -77,7 +77,7 @@ func testRangeNegative(t *testing.T, alt bool, desc *export.Descriptor) { func TestRangeTest(t *testing.T) { for _, nkind := range []core.NumberKind{core.Float64NumberKind, core.Int64NumberKind} { t.Run(nkind.String(), func(t *testing.T) { - for _, mkind := range []export.MetricKind{ + for _, mkind := range []export.Kind{ export.CounterKind, export.GaugeKind, export.MeasureKind, diff --git a/sdk/export/metric/kind_string.go b/sdk/export/metric/kind_string.go new file mode 100644 index 000000000000..e2d2b88f4666 --- /dev/null +++ b/sdk/export/metric/kind_string.go @@ -0,0 +1,25 @@ +// Code generated by "stringer -type=Kind"; DO NOT EDIT. + +package metric + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[CounterKind-0] + _ = x[GaugeKind-1] + _ = x[MeasureKind-2] +} + +const _Kind_name = "CounterKindGaugeKindMeasureKind" + +var _Kind_index = [...]uint8{0, 11, 20, 31} + +func (i Kind) String() string { + if i < 0 || i >= Kind(len(_Kind_index)-1) { + return "Kind(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _Kind_name[_Kind_index[i]:_Kind_index[i+1]] +} diff --git a/sdk/export/metric/metric.go b/sdk/export/metric/metric.go index 8a1731fc0755..dc8e5f7182c5 100644 --- a/sdk/export/metric/metric.go +++ b/sdk/export/metric/metric.go @@ -12,9 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -package export +package metric -//go:generate stringer -type=MetricKind +//go:generate stringer -type=Kind import ( "context" @@ -283,12 +283,12 @@ func (r Record) Labels() Labels { return r.labels } -// MetricKind describes the kind of instrument. -type MetricKind int8 +// Kind describes the kind of instrument. +type Kind int8 const ( // Counter kind indicates a counter instrument. - CounterKind MetricKind = iota + CounterKind Kind = iota // Gauge kind indicates a gauge instrument. GaugeKind @@ -304,7 +304,7 @@ const ( // exporter. type Descriptor struct { name string - metricKind MetricKind + metricKind Kind keys []core.Key description string unit unit.Unit @@ -320,7 +320,7 @@ type Descriptor struct { // exporter. func NewDescriptor( name string, - metricKind MetricKind, + metricKind Kind, keys []core.Key, description string, unit unit.Unit, @@ -345,7 +345,7 @@ func (d *Descriptor) Name() string { // MetricKind returns the kind of instrument: counter, gauge, or // measure. -func (d *Descriptor) MetricKind() MetricKind { +func (d *Descriptor) MetricKind() Kind { return d.metricKind } diff --git a/sdk/export/metric/metrickind_string.go b/sdk/export/metric/metrickind_string.go deleted file mode 100644 index 94ccadc5928e..000000000000 --- a/sdk/export/metric/metrickind_string.go +++ /dev/null @@ -1,25 +0,0 @@ -// Code generated by "stringer -type=MetricKind"; DO NOT EDIT. - -package export - -import "strconv" - -func _() { - // An "invalid array index" compiler error signifies that the constant values have changed. - // Re-run the stringer command to generate them again. - var x [1]struct{} - _ = x[CounterKind-0] - _ = x[GaugeKind-1] - _ = x[MeasureKind-2] -} - -const _MetricKind_name = "CounterKindGaugeKindMeasureKind" - -var _MetricKind_index = [...]uint8{0, 11, 20, 31} - -func (i MetricKind) String() string { - if i < 0 || i >= MetricKind(len(_MetricKind_index)-1) { - return "MetricKind(" + strconv.FormatInt(int64(i), 10) + ")" - } - return _MetricKind_name[_MetricKind_index[i]:_MetricKind_index[i+1]] -} diff --git a/sdk/metric/aggregator/test/test.go b/sdk/metric/aggregator/test/test.go index 582183fc189f..0657282820e2 100644 --- a/sdk/metric/aggregator/test/test.go +++ b/sdk/metric/aggregator/test/test.go @@ -53,7 +53,7 @@ func newProfiles() []Profile { } } -func NewAggregatorTest(mkind export.MetricKind, nkind core.NumberKind, alternate bool) *export.Descriptor { +func NewAggregatorTest(mkind export.Kind, nkind core.NumberKind, alternate bool) *export.Descriptor { desc := export.NewDescriptor("test.name", mkind, nil, "", "", nkind, alternate) return desc } diff --git a/sdk/metric/sdk.go b/sdk/metric/sdk.go index 5c15eca14bcc..29355b499a55 100644 --- a/sdk/metric/sdk.go +++ b/sdk/metric/sdk.go @@ -298,7 +298,7 @@ func (m *SDK) labsFor(ls api.LabelSet) *labels { return &m.empty } -func (m *SDK) newInstrument(name string, metricKind export.MetricKind, numberKind core.NumberKind, opts *api.Options) *instrument { +func (m *SDK) newInstrument(name string, metricKind export.Kind, numberKind core.NumberKind, opts *api.Options) *instrument { descriptor := export.NewDescriptor( name, metricKind,