diff --git a/go.mod b/go.mod index 38aeb7e0cc0..87aaa78f656 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ go 1.15 require ( github.com/google/go-cmp v0.5.6 github.com/stretchr/testify v1.7.0 + go.opentelemetry.io/otel/metric v0.21.0 go.opentelemetry.io/otel/oteltest v1.0.0-RC1 go.opentelemetry.io/otel/trace v1.0.0-RC1 ) diff --git a/go.sum b/go.sum index f212493d586..5281e24c559 100644 --- a/go.sum +++ b/go.sum @@ -7,6 +7,7 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +go.opentelemetry.io v0.1.0 h1:EANZoRCOP+A3faIlw/iN6YEWoYb1vleZRKm1EvH8T48= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= 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/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/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{} +}