Skip to content

Commit 56fe193

Browse files
thinkerourghetia
authored andcommitted
check interface implement for metric (#38)
1 parent 861e3e8 commit 56fe193

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

api/metric/api.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,6 @@ import (
2020
"github.com/open-telemetry/opentelemetry-go/api/unit"
2121
)
2222

23-
type Metric interface {
24-
Measure() core.Measure
25-
26-
DefinitionID() core.EventID
27-
28-
Type() MetricType
29-
Fields() []core.Key
30-
Err() error
31-
32-
base() *baseMetric
33-
}
3423
type MetricType int
3524

3625
const (
@@ -45,6 +34,18 @@ const (
4534
DerivedCumulativeFloat64
4635
)
4736

37+
type Metric interface {
38+
Measure() core.Measure
39+
40+
DefinitionID() core.EventID
41+
42+
Type() MetricType
43+
Fields() []core.Key
44+
Err() error
45+
46+
base() *baseMetric
47+
}
48+
4849
type Option func(*baseMetric, *[]tag.Option)
4950

5051
// WithDescription applies provided description.

api/metric/common.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ type baseEntry struct {
3636
eventID core.EventID
3737
}
3838

39+
var _ Metric = (*baseMetric)(nil)
40+
3941
func initBaseMetric(name string, mtype MetricType, opts []Option, init Metric) Metric {
4042
var tagOpts []tag.Option
4143
bm := init.base()

api/metric/registry.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ type registry struct {
4444
nameType sync.Map // map[string]Metric
4545
}
4646

47+
var _ Registry = (*registry)(nil)
48+
4749
var (
4850
registryLock sync.Mutex
4951
registryGlobal Registry = &registry{}

0 commit comments

Comments
 (0)