From 21c2edde94009776aeead3b85a88f8ebcc171537 Mon Sep 17 00:00:00 2001 From: Joshua MacDonald Date: Tue, 13 Jul 2021 13:37:21 -0700 Subject: [PATCH] remove instrument interfaces --- metric2/asyncfloat64/asyncfloat64.go | 38 +++++++ metric2/asyncint64/asyncint64.go | 38 +++++++ metric2/instrument.go | 24 ----- metric2/meter.go | 116 +++++++++++++++++++++ metric2/meter/asyncfloat64/asyncfloat64.go | 66 ------------ metric2/meter/asyncint64/asyncint64.go | 66 ------------ metric2/meter/meter.go | 59 ----------- metric2/meter/syncfloat64/syncfloat64.go | 65 ------------ metric2/meter/syncint64/syncint64.go | 67 ------------ metric2/sdkapi/sdkapi.go | 14 +++ metric2/syncfloat64/syncfloat64.go | 38 +++++++ metric2/syncint64/syncint64.go | 38 +++++++ 12 files changed, 282 insertions(+), 347 deletions(-) create mode 100644 metric2/asyncfloat64/asyncfloat64.go create mode 100644 metric2/asyncint64/asyncint64.go delete mode 100644 metric2/instrument.go create mode 100644 metric2/meter.go delete mode 100644 metric2/meter/asyncfloat64/asyncfloat64.go delete mode 100644 metric2/meter/asyncint64/asyncint64.go delete mode 100644 metric2/meter/meter.go delete mode 100644 metric2/meter/syncfloat64/syncfloat64.go delete mode 100644 metric2/meter/syncint64/syncint64.go create mode 100644 metric2/sdkapi/sdkapi.go create mode 100644 metric2/syncfloat64/syncfloat64.go create mode 100644 metric2/syncint64/syncint64.go diff --git a/metric2/asyncfloat64/asyncfloat64.go b/metric2/asyncfloat64/asyncfloat64.go new file mode 100644 index 00000000000..ffcc7009a98 --- /dev/null +++ b/metric2/asyncfloat64/asyncfloat64.go @@ -0,0 +1,38 @@ +package asyncfloat64 + +import ( + "context" + + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/metric2/sdkapi" +) + +type Counter struct { +} + +type UpDownCounter struct { +} + +type Gauge struct { +} + +func (c Counter) Observe(ctx context.Context, x float64, attrs ...attribute.KeyValue) { +} + +func (u UpDownCounter) Observe(ctx context.Context, x float64, attrs ...attribute.KeyValue) { +} + +func (g Gauge) Observe(ctx context.Context, x float64, attrs ...attribute.KeyValue) { +} + +func (c Counter) Measure(x float64) sdkapi.Measurement { + return sdkapi.Measurement{} +} + +func (u UpDownCounter) Measure(x float64) sdkapi.Measurement { + return sdkapi.Measurement{} +} + +func (g Gauge) Measure(x float64) sdkapi.Measurement { + return sdkapi.Measurement{} +} diff --git a/metric2/asyncint64/asyncint64.go b/metric2/asyncint64/asyncint64.go new file mode 100644 index 00000000000..0dc290d26b1 --- /dev/null +++ b/metric2/asyncint64/asyncint64.go @@ -0,0 +1,38 @@ +package asyncint64 + +import ( + "context" + + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/metric2/sdkapi" +) + +type Counter struct { +} + +type UpDownCounter struct { +} + +type Gauge struct { +} + +func (c Counter) Observe(ctx context.Context, x int64, attrs ...attribute.KeyValue) { +} + +func (u UpDownCounter) Observe(ctx context.Context, x int64, attrs ...attribute.KeyValue) { +} + +func (g Gauge) Observe(ctx context.Context, x int64, attrs ...attribute.KeyValue) { +} + +func (c Counter) Measure(x int64) sdkapi.Measurement { + return sdkapi.Measurement{} +} + +func (u UpDownCounter) Measure(x int64) sdkapi.Measurement { + return sdkapi.Measurement{} +} + +func (g Gauge) Measure(x int64) sdkapi.Measurement { + return sdkapi.Measurement{} +} diff --git a/metric2/instrument.go b/metric2/instrument.go deleted file mode 100644 index d6e02bc5311..00000000000 --- a/metric2/instrument.go +++ /dev/null @@ -1,24 +0,0 @@ -package metric2 - -import ( - "go.opentelemetry.io/otel/metric/number" -) - -// Measurement represents a single measurement made on a specific -// instrument. The encapsulated number's Kind matches the instrument -// definition. -type Measurement struct { - instrument Instrument - number number.Number -} - -// Instrument is a base -type Instrument interface { - // Implementation returns the underlying implementation of the - // instrument, which allows the SDK to gain access to its own - // representation especially from a `Measurement`. - // Implementation() interface{} - - // Descriptor returns a copy of the instrument's Descriptor. - // Descriptor() metric.Descriptor -} diff --git a/metric2/meter.go b/metric2/meter.go new file mode 100644 index 00000000000..6800c19e008 --- /dev/null +++ b/metric2/meter.go @@ -0,0 +1,116 @@ +package meter + +import ( + "context" + + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/metric2/asyncfloat64" + "go.opentelemetry.io/otel/metric2/asyncint64" + "go.opentelemetry.io/otel/metric2/sdkapi" + "go.opentelemetry.io/otel/metric2/syncfloat64" + "go.opentelemetry.io/otel/metric2/syncint64" +) + +type MeterOption = metric.MeterOption +type InstrumentOption = metric.InstrumentOption + +// Provider supports creating named Meter instances, for instrumenting +// an application containing multiple libraries of code. +type Provider interface { + Meter(instrumentationName string, opts ...MeterOption) Meter +} + +// Meter is an instance of an OpenTelemetry metrics interface for an +// individual named library of code. This is the top-level entry +// point for creating instruments. +type Meter struct { +} + +type AsyncFloat64Instruments struct{} +type AsyncInt64Instruments struct{} +type SyncFloat64Instruments struct{} +type SyncInt64Instruments struct{} + +func (m Meter) AsyncInt64() AsyncInt64Instruments { + return AsyncInt64Instruments{} +} + +func (m Meter) AsyncFloat64() AsyncFloat64Instruments { + return AsyncFloat64Instruments{} +} + +func (m Meter) SyncInt64() SyncInt64Instruments { + return SyncInt64Instruments{} +} + +func (m Meter) SyncFloat64() SyncFloat64Instruments { + return SyncFloat64Instruments{} +} + +// ProcessBatch processes a batch of measurements as a single logical +// event. +func (m Meter) ProcessBatch( + ctx context.Context, + attrs []attribute.KeyValue, + batch ...sdkapi.Measurement) { +} + +// Process processes a single measurement. This offers the +// convenience of passing a variable length list of attributes for a +// processing a single measurement. +func (m Meter) Process( + ctx context.Context, + ms sdkapi.Measurement, + attrs ...attribute.KeyValue) { + // Process a singleton batch + m.ProcessBatch(ctx, attrs, ms) +} + +func (m AsyncFloat64Instruments) Counter(name string, opts ...InstrumentOption) (asyncfloat64.Counter, error) { + return asyncfloat64.Counter{}, nil +} + +func (m AsyncFloat64Instruments) UpDownCounter(name string, opts ...InstrumentOption) (asyncfloat64.UpDownCounter, error) { + return asyncfloat64.UpDownCounter{}, nil +} + +func (m AsyncFloat64Instruments) Gauge(name string, opts ...InstrumentOption) (asyncfloat64.Gauge, error) { + return asyncfloat64.Gauge{}, nil +} + +func (m AsyncInt64Instruments) Counter(name string, opts ...InstrumentOption) (asyncint64.Counter, error) { + return asyncint64.Counter{}, nil +} + +func (m AsyncInt64Instruments) UpDownCounter(name string, opts ...InstrumentOption) (asyncint64.UpDownCounter, error) { + return asyncint64.UpDownCounter{}, nil +} + +func (m AsyncInt64Instruments) Gauge(name string, opts ...InstrumentOption) (asyncint64.Gauge, error) { + return asyncint64.Gauge{}, nil +} + +func (m SyncFloat64Instruments) Counter(name string, opts ...InstrumentOption) (syncfloat64.Counter, error) { + return syncfloat64.Counter{}, nil +} + +func (m SyncFloat64Instruments) UpDownCounter(name string, opts ...InstrumentOption) (syncfloat64.UpDownCounter, error) { + return syncfloat64.UpDownCounter{}, nil +} + +func (m SyncFloat64Instruments) Histogram(name string, opts ...InstrumentOption) (syncfloat64.Histogram, error) { + return syncfloat64.Histogram{}, nil +} + +func (m SyncInt64Instruments) Counter(name string, opts ...InstrumentOption) (syncint64.Counter, error) { + return syncint64.Counter{}, nil +} + +func (m SyncInt64Instruments) UpDownCounter(name string, opts ...InstrumentOption) (syncint64.UpDownCounter, error) { + return syncint64.UpDownCounter{}, nil +} + +func (m SyncInt64Instruments) Histogram(name string, opts ...InstrumentOption) (syncint64.Histogram, error) { + return syncint64.Histogram{}, nil +} diff --git a/metric2/meter/asyncfloat64/asyncfloat64.go b/metric2/meter/asyncfloat64/asyncfloat64.go deleted file mode 100644 index b221c54875d..00000000000 --- a/metric2/meter/asyncfloat64/asyncfloat64.go +++ /dev/null @@ -1,66 +0,0 @@ -package asyncfloat64 - -import ( - "context" - - "go.opentelemetry.io/otel/attribute" - metric "go.opentelemetry.io/otel/metric2" -) - -type Builder struct { -} - -type Counter struct { -} - -type UpDownCounter struct { -} - -type Gauge struct { -} - -type Instrument interface { - metric.Instrument - - Observe(ctx context.Context, x float64, attrs ...attribute.KeyValue) - Measure(x float64) metric.Measurement -} - -var ( - _ Instrument = Counter{} - _ Instrument = UpDownCounter{} - _ Instrument = Gauge{} -) - -func (m Builder) Counter(name string) (Counter, error) { - return Counter{}, nil -} - -func (m Builder) UpDownCounter(name string) (UpDownCounter, error) { - return UpDownCounter{}, nil -} - -func (m Builder) Gauge(name string) (Gauge, error) { - return Gauge{}, nil -} - -func (c Counter) Observe(ctx context.Context, x float64, attrs ...attribute.KeyValue) { -} - -func (u UpDownCounter) Observe(ctx context.Context, x float64, attrs ...attribute.KeyValue) { -} - -func (g Gauge) Observe(ctx context.Context, x float64, attrs ...attribute.KeyValue) { -} - -func (c Counter) Measure(x float64) metric.Measurement { - return metric.Measurement{} -} - -func (u UpDownCounter) Measure(x float64) metric.Measurement { - return metric.Measurement{} -} - -func (g Gauge) Measure(x float64) metric.Measurement { - return metric.Measurement{} -} diff --git a/metric2/meter/asyncint64/asyncint64.go b/metric2/meter/asyncint64/asyncint64.go deleted file mode 100644 index cf5ea6f7c6b..00000000000 --- a/metric2/meter/asyncint64/asyncint64.go +++ /dev/null @@ -1,66 +0,0 @@ -package asyncint64 - -import ( - "context" - - "go.opentelemetry.io/otel/attribute" - metric "go.opentelemetry.io/otel/metric2" -) - -type Builder struct { -} - -type Counter struct { -} - -type UpDownCounter struct { -} - -type Gauge struct { -} - -type Instrument interface { - metric.Instrument - - Observe(ctx context.Context, x int64, attrs ...attribute.KeyValue) - Measure(x int64) metric.Measurement -} - -var ( - _ Instrument = Counter{} - _ Instrument = UpDownCounter{} - _ Instrument = Gauge{} -) - -func (m Builder) Counter(name string) (Counter, error) { - return Counter{}, nil -} - -func (m Builder) UpDownCounter(name string) (UpDownCounter, error) { - return UpDownCounter{}, nil -} - -func (m Builder) Gauge(name string) (Gauge, error) { - return Gauge{}, nil -} - -func (c Counter) Observe(ctx context.Context, x int64, attrs ...attribute.KeyValue) { -} - -func (u UpDownCounter) Observe(ctx context.Context, x int64, attrs ...attribute.KeyValue) { -} - -func (g Gauge) Observe(ctx context.Context, x int64, attrs ...attribute.KeyValue) { -} - -func (c Counter) Measure(x int64) metric.Measurement { - return metric.Measurement{} -} - -func (u UpDownCounter) Measure(x int64) metric.Measurement { - return metric.Measurement{} -} - -func (g Gauge) Measure(x int64) metric.Measurement { - return metric.Measurement{} -} diff --git a/metric2/meter/meter.go b/metric2/meter/meter.go deleted file mode 100644 index 00a60d38d63..00000000000 --- a/metric2/meter/meter.go +++ /dev/null @@ -1,59 +0,0 @@ -package meter - -import ( - "context" - - "go.opentelemetry.io/otel/attribute" - "go.opentelemetry.io/otel/metric" - "go.opentelemetry.io/otel/metric2/meter/asyncfloat64" - "go.opentelemetry.io/otel/metric2/meter/asyncint64" - "go.opentelemetry.io/otel/metric2/meter/syncfloat64" - "go.opentelemetry.io/otel/metric2/meter/syncint64" -) - -// MeterProvider supports creating named Meter instances, for -// instrumenting an application containing multiple libraries of code. -type MeterProvider interface { - Meter(instrumentationName string /*, opts ...MeterOption*/) Meter -} - -// Meter is an instance of an OpenTelemetry metrics interface for an -// individual named library of code. This is the top-level entry -// point for creating instruments. -type Meter struct { -} - -func (m Meter) AsyncInt64() asyncint64.Builder { - return asyncint64.Builder{} -} - -func (m Meter) AsyncFloat64() asyncfloat64.Builder { - return asyncfloat64.Builder{} -} - -func (m Meter) SyncInt64() syncint64.Builder { - return syncint64.Builder{} -} - -func (m Meter) SyncFloat64() syncfloat64.Builder { - return syncfloat64.Builder{} -} - -// ProcessBatch processes a batch of measurements as a single logical -// event. -func (m Meter) ProcessBatch( - ctx context.Context, - attrs []attribute.KeyValue, - batch ...metric.Measurement) { -} - -// Process processes a single measurement. This offers the -// convenience of passing a variable length list of attributes for a -// processing a single measurement. -func (m Meter) Process( - ctx context.Context, - ms metric.Measurement, - attrs ...attribute.KeyValue) { - // Process a singleton batch - m.ProcessBatch(ctx, attrs, ms) -} diff --git a/metric2/meter/syncfloat64/syncfloat64.go b/metric2/meter/syncfloat64/syncfloat64.go deleted file mode 100644 index 3fa10eb2c55..00000000000 --- a/metric2/meter/syncfloat64/syncfloat64.go +++ /dev/null @@ -1,65 +0,0 @@ -package syncfloat64 - -import ( - "context" - - "go.opentelemetry.io/otel/attribute" - metric "go.opentelemetry.io/otel/metric2" -) - -type Builder struct { -} - -type Counter struct { -} - -type UpDownCounter struct { -} - -type Histogram struct { -} - -type Instrument interface { - metric.Instrument - - Measure(x float64) metric.Measurement -} - -var ( - _ Instrument = Counter{} - _ Instrument = UpDownCounter{} - _ Instrument = Histogram{} -) - -func (m Builder) Counter(name string) (Counter, error) { - return Counter{}, nil -} - -func (m Builder) UpDownCounter(name string) (UpDownCounter, error) { - return UpDownCounter{}, nil -} - -func (m Builder) Histogram(name string) (Histogram, error) { - return Histogram{}, nil -} - -func (c Counter) Add(ctx context.Context, x float64, attrs ...attribute.KeyValue) { -} - -func (u UpDownCounter) Add(ctx context.Context, x float64, attrs ...attribute.KeyValue) { -} - -func (h Histogram) Record(ctx context.Context, x float64, attrs ...attribute.KeyValue) { -} - -func (c Counter) Measure(x float64) metric.Measurement { - return metric.Measurement{} -} - -func (u UpDownCounter) Measure(x float64) metric.Measurement { - return metric.Measurement{} -} - -func (h Histogram) Measure(x float64) metric.Measurement { - return metric.Measurement{} -} diff --git a/metric2/meter/syncint64/syncint64.go b/metric2/meter/syncint64/syncint64.go deleted file mode 100644 index b1af58b1b7a..00000000000 --- a/metric2/meter/syncint64/syncint64.go +++ /dev/null @@ -1,67 +0,0 @@ -package syncint64 - -import ( - "context" - - "go.opentelemetry.io/otel/attribute" - metric "go.opentelemetry.io/otel/metric2" -) - -// TODO instrument options - -type Builder struct { -} - -type Counter struct { -} - -type UpDownCounter struct { -} - -type Histogram struct { -} - -type Instrument interface { - metric.Instrument - - Measure(x int64) metric.Measurement -} - -var ( - _ Instrument = Counter{} - _ Instrument = UpDownCounter{} - _ Instrument = Histogram{} -) - -func (m Builder) Counter(name string) (Counter, error) { - return Counter{}, nil -} - -func (m Builder) UpDownCounter(name string) (UpDownCounter, error) { - return UpDownCounter{}, nil -} - -func (m Builder) Histogram(name string) (Histogram, error) { - return Histogram{}, nil -} - -func (c Counter) Add(ctx context.Context, x int64, attrs ...attribute.KeyValue) { -} - -func (u UpDownCounter) Add(ctx context.Context, x int64, attrs ...attribute.KeyValue) { -} - -func (h Histogram) Record(ctx context.Context, x int64, attrs ...attribute.KeyValue) { -} - -func (c Counter) Measure(x int64) metric.Measurement { - return metric.Measurement{} -} - -func (u UpDownCounter) Measure(x int64) metric.Measurement { - return metric.Measurement{} -} - -func (h Histogram) Measure(x int64) metric.Measurement { - return metric.Measurement{} -} diff --git a/metric2/sdkapi/sdkapi.go b/metric2/sdkapi/sdkapi.go new file mode 100644 index 00000000000..54f34fc35a7 --- /dev/null +++ b/metric2/sdkapi/sdkapi.go @@ -0,0 +1,14 @@ +package sdkapi + +import "go.opentelemetry.io/otel/metric/number" + +// Measurement represents a single measurement made on a specific +// instrument. The encapsulated number's Kind matches the instrument +// definition. +type Measurement struct { + instrument Instrument + number number.Number +} + +type Instrument interface { +} diff --git a/metric2/syncfloat64/syncfloat64.go b/metric2/syncfloat64/syncfloat64.go new file mode 100644 index 00000000000..8ad73797d03 --- /dev/null +++ b/metric2/syncfloat64/syncfloat64.go @@ -0,0 +1,38 @@ +package syncfloat64 + +import ( + "context" + + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/metric2/sdkapi" +) + +type Counter struct { +} + +type UpDownCounter struct { +} + +type Histogram struct { +} + +func (c Counter) Add(ctx context.Context, x float64, attrs ...attribute.KeyValue) { +} + +func (u UpDownCounter) Add(ctx context.Context, x float64, attrs ...attribute.KeyValue) { +} + +func (h Histogram) Record(ctx context.Context, x float64, attrs ...attribute.KeyValue) { +} + +func (c Counter) Measure(x float64) sdkapi.Measurement { + return sdkapi.Measurement{} +} + +func (u UpDownCounter) Measure(x float64) sdkapi.Measurement { + return sdkapi.Measurement{} +} + +func (h Histogram) Measure(x float64) sdkapi.Measurement { + return sdkapi.Measurement{} +} diff --git a/metric2/syncint64/syncint64.go b/metric2/syncint64/syncint64.go new file mode 100644 index 00000000000..fbeb2c3c5f0 --- /dev/null +++ b/metric2/syncint64/syncint64.go @@ -0,0 +1,38 @@ +package syncint64 + +import ( + "context" + + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/metric2/sdkapi" +) + +type Counter struct { +} + +type UpDownCounter struct { +} + +type Histogram struct { +} + +func (c Counter) Add(ctx context.Context, x int64, attrs ...attribute.KeyValue) { +} + +func (u UpDownCounter) Add(ctx context.Context, x int64, attrs ...attribute.KeyValue) { +} + +func (h Histogram) Record(ctx context.Context, x int64, attrs ...attribute.KeyValue) { +} + +func (c Counter) Measure(x int64) sdkapi.Measurement { + return sdkapi.Measurement{} +} + +func (u UpDownCounter) Measure(x int64) sdkapi.Measurement { + return sdkapi.Measurement{} +} + +func (h Histogram) Measure(x int64) sdkapi.Measurement { + return sdkapi.Measurement{} +}