Skip to content

Commit

Permalink
check interface implement for metric (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkerou authored and rghetia committed Jul 1, 2019
1 parent 861e3e8 commit 56fe193
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
23 changes: 12 additions & 11 deletions api/metric/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,6 @@ import (
"github.com/open-telemetry/opentelemetry-go/api/unit"
)

type Metric interface {
Measure() core.Measure

DefinitionID() core.EventID

Type() MetricType
Fields() []core.Key
Err() error

base() *baseMetric
}
type MetricType int

const (
Expand All @@ -45,6 +34,18 @@ const (
DerivedCumulativeFloat64
)

type Metric interface {
Measure() core.Measure

DefinitionID() core.EventID

Type() MetricType
Fields() []core.Key
Err() error

base() *baseMetric
}

type Option func(*baseMetric, *[]tag.Option)

// WithDescription applies provided description.
Expand Down
2 changes: 2 additions & 0 deletions api/metric/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ type baseEntry struct {
eventID core.EventID
}

var _ Metric = (*baseMetric)(nil)

func initBaseMetric(name string, mtype MetricType, opts []Option, init Metric) Metric {
var tagOpts []tag.Option
bm := init.base()
Expand Down
2 changes: 2 additions & 0 deletions api/metric/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ type registry struct {
nameType sync.Map // map[string]Metric
}

var _ Registry = (*registry)(nil)

var (
registryLock sync.Mutex
registryGlobal Registry = &registry{}
Expand Down

0 comments on commit 56fe193

Please sign in to comment.