Skip to content

Commit

Permalink
Refactor the SDK helpers, create MeterImpl (#560)
Browse files Browse the repository at this point in the history
* Create MeterImpl interface

* Checkpoint w/ sdk.go building

* Checkpoint working on global

* api/global builds (test fails)

* Test fix

* All tests pass

* Comments

* Add two tests

* Comments and uncomment tests

* Precommit part 1

* Still working on tests

* Lint

* Add a test and a TODO

* Cleanup

* Lint

* Interface()->Implementation()

* Apply some feedback

* From feedback

* (A)Synchronous -> (A)Sync

* Add a missing comment

* Apply suggestions from code review

Co-Authored-By: Krzesimir Nowak <[email protected]>

* Rename a variable

Co-authored-by: Krzesimir Nowak <[email protected]>
  • Loading branch information
jmacd and krnowak authored Mar 19, 2020
1 parent e0406dd commit d8682c1
Show file tree
Hide file tree
Showing 55 changed files with 1,298 additions and 1,283 deletions.
14 changes: 8 additions & 6 deletions api/global/internal/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ var Must = metric.Must
// benchFixture is copied from sdk/metric/benchmark_test.go.
// TODO refactor to share this code.
type benchFixture struct {
sdk *sdk.SDK
B *testing.B
sdk *sdk.SDK
meter metric.Meter
B *testing.B
}

var _ metric.Provider = &benchFixture{}
Expand All @@ -35,14 +36,15 @@ func newFixture(b *testing.B) *benchFixture {
B: b,
}
bf.sdk = sdk.New(bf, sdk.NewDefaultLabelEncoder())
bf.meter = metric.WrapMeterImpl(bf.sdk)
return bf
}

func (*benchFixture) AggregatorFor(descriptor *export.Descriptor) export.Aggregator {
func (*benchFixture) AggregatorFor(descriptor *metric.Descriptor) export.Aggregator {
switch descriptor.MetricKind() {
case export.CounterKind:
case metric.CounterKind:
return sum.New()
case export.MeasureKind:
case metric.MeasureKind:
if strings.HasSuffix(descriptor.Name(), "minmaxsumcount") {
return minmaxsumcount.New(descriptor)
} else if strings.HasSuffix(descriptor.Name(), "ddsketch") {
Expand All @@ -66,7 +68,7 @@ func (*benchFixture) FinishedCollection() {
}

func (fix *benchFixture) Meter(name string) metric.Meter {
return fix.sdk
return fix.meter
}

func BenchmarkGlobalInt64CounterAddNoSDK(b *testing.B) {
Expand Down
Loading

0 comments on commit d8682c1

Please sign in to comment.