1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2024-12-04 09:43:23 +02:00

Remove GetDescriptor (#575)

* Remove GetDescriptor

* Add Must var hotfix
This commit is contained in:
Ilya Kaznacheev 2020-03-21 03:19:48 +03:00 committed by GitHub
parent c95360fc06
commit 7623fc544a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 15 deletions

View File

@ -594,16 +594,6 @@ func (m *SDK) RecordBatch(ctx context.Context, ls api.LabelSet, measurements ...
}
}
// GetDescriptor returns a pointer to the descriptor of an instrument,
// which is not part of the public metric API. This is for testing. Use
// SyncImpl().Descriptor() to get a copy of the descriptor.
func (m *SDK) GetDescriptor(inst api.SyncImpl) *metric.Descriptor {
if ii, ok := inst.(*syncInstrument); ok {
return &ii.descriptor
}
return nil
}
func (r *record) RecordOne(ctx context.Context, number core.Number) {
if r.recorder == nil {
// The instrument is disabled according to the AggregationSelector.

View File

@ -16,7 +16,7 @@
// that the race detector would help with, anyway.
// +build !race
package metric_test
package metric
import (
"context"
@ -37,7 +37,6 @@ import (
api "go.opentelemetry.io/otel/api/metric"
export "go.opentelemetry.io/otel/sdk/export/metric"
"go.opentelemetry.io/otel/sdk/export/metric/aggregator"
sdk "go.opentelemetry.io/otel/sdk/metric"
"go.opentelemetry.io/otel/sdk/metric/aggregator/lastvalue"
"go.opentelemetry.io/otel/sdk/metric/aggregator/sum"
)
@ -49,6 +48,8 @@ const (
epsilon = 1e-10
)
var Must = api.Must
type (
testFixture struct {
// stop has to be aligned for 64-bit atomic operations.
@ -156,11 +157,14 @@ func (f *testFixture) someLabels() []core.KeyValue {
}
}
func (f *testFixture) startWorker(impl *sdk.SDK, meter api.Meter, wg *sync.WaitGroup, i int) {
func (f *testFixture) startWorker(impl *SDK, meter api.Meter, wg *sync.WaitGroup, i int) {
ctx := context.Background()
name := fmt.Sprint("test_", i)
instrument := f.impl.newInstrument(meter, name)
descriptor := impl.GetDescriptor(instrument.SyncImpl())
var descriptor *metric.Descriptor
if ii, ok := instrument.SyncImpl().(*syncInstrument); ok {
descriptor = &ii.descriptor
}
kvs := f.someLabels()
clabs := canonicalizeLabels(kvs)
labs := meter.Labels(kvs...)
@ -292,7 +296,7 @@ func stressTest(t *testing.T, impl testImpl) {
lused: map[string]bool{},
}
cc := concurrency()
sdk := sdk.New(fixture, sdk.NewDefaultLabelEncoder())
sdk := New(fixture, NewDefaultLabelEncoder())
meter := metric.WrapMeterImpl(sdk)
fixture.wg.Add(cc + 1)