Skip to content

Commit

Permalink
Merge branch 'main' into jmacd/retryable_err
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlias authored Jan 4, 2023
2 parents 8e9f37f + 4607516 commit 5d5859a
Show file tree
Hide file tree
Showing 11 changed files with 172 additions and 165 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,14 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- `traceIDRatioSampler` (given by `TraceIDRatioBased(float64)`) now uses the rightmost bits for sampling decisions,
fixing random sampling when using ID generators like `xray.IDGenerator`
and increasing parity with other language implementations. (#3557)
- OTLP exporter for traces and metrics will print the final retryable error message
when attempts to retry time out. (#3514)
- The OTLP exporter for traces and metrics will print the final retryable error message when attempts to retry time out. (#3514)
- The instrument kind names in `go.opentelemetry.io/otel/sdk/metric` are updated to match the API. (#3562)
- `InstrumentKindSyncCounter` is renamed to `InstrumentKindCounter`
- `InstrumentKindSyncUpDownCounter` is renamed to `InstrumentKindUpDownCounter`
- `InstrumentKindSyncHistogram` is renamed to `InstrumentKindHistogram`
- `InstrumentKindAsyncCounter` is renamed to `InstrumentKindObservableCounter`
- `InstrumentKindAsyncUpDownCounter` is renamed to `InstrumentKindObservableUpDownCounter`
- `InstrumentKindAsyncGauge` is renamed to `InstrumentKindObservableGauge`

### Deprecated

Expand Down
4 changes: 2 additions & 2 deletions sdk/metric/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ func TestWithReader(t *testing.T) {
func TestWithView(t *testing.T) {
c := newConfig([]Option{WithView(
NewView(
Instrument{Kind: InstrumentKindAsyncCounter},
Instrument{Kind: InstrumentKindObservableCounter},
Stream{Name: "a"},
),
NewView(
Instrument{Kind: InstrumentKindSyncCounter},
Instrument{Kind: InstrumentKindCounter},
Stream{Name: "b"},
),
)})
Expand Down
35 changes: 18 additions & 17 deletions sdk/metric/instrument.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,27 @@ const (
// instrumentKindUndefined is an undefined instrument kind, it should not
// be used by any initialized type.
instrumentKindUndefined InstrumentKind = iota // nolint:deadcode,varcheck,unused
// InstrumentKindSyncCounter identifies a group of instruments that record
// InstrumentKindCounter identifies a group of instruments that record
// increasing values synchronously with the code path they are measuring.
InstrumentKindSyncCounter
// InstrumentKindSyncUpDownCounter identifies a group of instruments that
InstrumentKindCounter
// InstrumentKindUpDownCounter identifies a group of instruments that
// record increasing and decreasing values synchronously with the code path
// they are measuring.
InstrumentKindSyncUpDownCounter
// InstrumentKindSyncHistogram identifies a group of instruments that
// record a distribution of values synchronously with the code path they
// are measuring.
InstrumentKindSyncHistogram
// InstrumentKindAsyncCounter identifies a group of instruments that record
// increasing values in an asynchronous callback.
InstrumentKindAsyncCounter
// InstrumentKindAsyncUpDownCounter identifies a group of instruments that
// record increasing and decreasing values in an asynchronous callback.
InstrumentKindAsyncUpDownCounter
// InstrumentKindAsyncGauge identifies a group of instruments that record
// current values in an asynchronous callback.
InstrumentKindAsyncGauge
InstrumentKindUpDownCounter
// InstrumentKindHistogram identifies a group of instruments that record a
// distribution of values synchronously with the code path they are
// measuring.
InstrumentKindHistogram
// InstrumentKindObservableCounter identifies a group of instruments that
// record increasing values in an asynchronous callback.
InstrumentKindObservableCounter
// InstrumentKindObservableUpDownCounter identifies a group of instruments
// that record increasing and decreasing values in an asynchronous
// callback.
InstrumentKindObservableUpDownCounter
// InstrumentKindObservableGauge identifies a group of instruments that
// record current values in an asynchronous callback.
InstrumentKindObservableGauge
)

type nonComparable [0]func() // nolint: unused // This is indeed used.
Expand Down
24 changes: 12 additions & 12 deletions sdk/metric/meter.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,84 +61,84 @@ var _ metric.Meter = (*meter)(nil)
// options. The instrument is used to synchronously record increasing int64
// measurements during a computational operation.
func (m *meter) Int64Counter(name string, options ...instrument.Option) (syncint64.Counter, error) {
return m.instProviderInt64.lookup(InstrumentKindSyncCounter, name, options)
return m.instProviderInt64.lookup(InstrumentKindCounter, name, options)
}

// Int64UpDownCounter returns a new instrument identified by name and
// configured with options. The instrument is used to synchronously record
// int64 measurements during a computational operation.
func (m *meter) Int64UpDownCounter(name string, options ...instrument.Option) (syncint64.UpDownCounter, error) {
return m.instProviderInt64.lookup(InstrumentKindSyncUpDownCounter, name, options)
return m.instProviderInt64.lookup(InstrumentKindUpDownCounter, name, options)
}

// Int64Histogram returns a new instrument identified by name and configured
// with options. The instrument is used to synchronously record the
// distribution of int64 measurements during a computational operation.
func (m *meter) Int64Histogram(name string, options ...instrument.Option) (syncint64.Histogram, error) {
return m.instProviderInt64.lookup(InstrumentKindSyncHistogram, name, options)
return m.instProviderInt64.lookup(InstrumentKindHistogram, name, options)
}

// Int64ObservableCounter returns a new instrument identified by name and
// configured with options. The instrument is used to asynchronously record
// increasing int64 measurements once per a measurement collection cycle.
func (m *meter) Int64ObservableCounter(name string, options ...instrument.Option) (asyncint64.Counter, error) {
return m.instProviderInt64.lookup(InstrumentKindAsyncCounter, name, options)
return m.instProviderInt64.lookup(InstrumentKindObservableCounter, name, options)
}

// Int64ObservableUpDownCounter returns a new instrument identified by name and
// configured with options. The instrument is used to asynchronously record
// int64 measurements once per a measurement collection cycle.
func (m *meter) Int64ObservableUpDownCounter(name string, options ...instrument.Option) (asyncint64.UpDownCounter, error) {
return m.instProviderInt64.lookup(InstrumentKindAsyncUpDownCounter, name, options)
return m.instProviderInt64.lookup(InstrumentKindObservableUpDownCounter, name, options)
}

// Int64ObservableGauge returns a new instrument identified by name and
// configured with options. The instrument is used to asynchronously record
// instantaneous int64 measurements once per a measurement collection cycle.
func (m *meter) Int64ObservableGauge(name string, options ...instrument.Option) (asyncint64.Gauge, error) {
return m.instProviderInt64.lookup(InstrumentKindAsyncGauge, name, options)
return m.instProviderInt64.lookup(InstrumentKindObservableGauge, name, options)
}

// Float64Counter returns a new instrument identified by name and configured
// with options. The instrument is used to synchronously record increasing
// float64 measurements during a computational operation.
func (m *meter) Float64Counter(name string, options ...instrument.Option) (syncfloat64.Counter, error) {
return m.instProviderFloat64.lookup(InstrumentKindSyncCounter, name, options)
return m.instProviderFloat64.lookup(InstrumentKindCounter, name, options)
}

// Float64UpDownCounter returns a new instrument identified by name and
// configured with options. The instrument is used to synchronously record
// float64 measurements during a computational operation.
func (m *meter) Float64UpDownCounter(name string, options ...instrument.Option) (syncfloat64.UpDownCounter, error) {
return m.instProviderFloat64.lookup(InstrumentKindSyncUpDownCounter, name, options)
return m.instProviderFloat64.lookup(InstrumentKindUpDownCounter, name, options)
}

// Float64Histogram returns a new instrument identified by name and configured
// with options. The instrument is used to synchronously record the
// distribution of float64 measurements during a computational operation.
func (m *meter) Float64Histogram(name string, options ...instrument.Option) (syncfloat64.Histogram, error) {
return m.instProviderFloat64.lookup(InstrumentKindSyncHistogram, name, options)
return m.instProviderFloat64.lookup(InstrumentKindHistogram, name, options)
}

// Float64ObservableCounter returns a new instrument identified by name and
// configured with options. The instrument is used to asynchronously record
// increasing float64 measurements once per a measurement collection cycle.
func (m *meter) Float64ObservableCounter(name string, options ...instrument.Option) (asyncfloat64.Counter, error) {
return m.instProviderFloat64.lookup(InstrumentKindAsyncCounter, name, options)
return m.instProviderFloat64.lookup(InstrumentKindObservableCounter, name, options)
}

// Float64ObservableUpDownCounter returns a new instrument identified by name
// and configured with options. The instrument is used to asynchronously record
// float64 measurements once per a measurement collection cycle.
func (m *meter) Float64ObservableUpDownCounter(name string, options ...instrument.Option) (asyncfloat64.UpDownCounter, error) {
return m.instProviderFloat64.lookup(InstrumentKindAsyncUpDownCounter, name, options)
return m.instProviderFloat64.lookup(InstrumentKindObservableUpDownCounter, name, options)
}

// Float64ObservableGauge returns a new instrument identified by name and
// configured with options. The instrument is used to asynchronously record
// instantaneous float64 measurements once per a measurement collection cycle.
func (m *meter) Float64ObservableGauge(name string, options ...instrument.Option) (asyncfloat64.Gauge, error) {
return m.instProviderFloat64.lookup(InstrumentKindAsyncGauge, name, options)
return m.instProviderFloat64.lookup(InstrumentKindObservableGauge, name, options)
}

// RegisterCallback registers the function f to be called when any of the
Expand Down
36 changes: 18 additions & 18 deletions sdk/metric/meter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func TestMeterCreatesInstruments(t *testing.T) {
want metricdata.Metrics
}{
{
name: "AsyncInt64Count",
name: "ObservableInt64Count",
fn: func(t *testing.T, m metric.Meter) {
ctr, err := m.Int64ObservableCounter("aint")
assert.NoError(t, err)
Expand All @@ -198,7 +198,7 @@ func TestMeterCreatesInstruments(t *testing.T) {
},
},
{
name: "AsyncInt64UpDownCount",
name: "ObservableInt64UpDownCount",
fn: func(t *testing.T, m metric.Meter) {
ctr, err := m.Int64ObservableUpDownCounter("aint")
assert.NoError(t, err)
Expand All @@ -222,7 +222,7 @@ func TestMeterCreatesInstruments(t *testing.T) {
},
},
{
name: "AsyncInt64Gauge",
name: "ObservableInt64Gauge",
fn: func(t *testing.T, m metric.Meter) {
gauge, err := m.Int64ObservableGauge("agauge")
assert.NoError(t, err)
Expand All @@ -244,7 +244,7 @@ func TestMeterCreatesInstruments(t *testing.T) {
},
},
{
name: "AsyncFloat64Count",
name: "ObservableFloat64Count",
fn: func(t *testing.T, m metric.Meter) {
ctr, err := m.Float64ObservableCounter("afloat")
assert.NoError(t, err)
Expand All @@ -268,7 +268,7 @@ func TestMeterCreatesInstruments(t *testing.T) {
},
},
{
name: "AsyncFloat64UpDownCount",
name: "ObservableFloat64UpDownCount",
fn: func(t *testing.T, m metric.Meter) {
ctr, err := m.Float64ObservableUpDownCounter("afloat")
assert.NoError(t, err)
Expand All @@ -292,7 +292,7 @@ func TestMeterCreatesInstruments(t *testing.T) {
},
},
{
name: "AsyncFloat64Gauge",
name: "ObservableFloat64Gauge",
fn: func(t *testing.T, m metric.Meter) {
gauge, err := m.Float64ObservableGauge("agauge")
assert.NoError(t, err)
Expand Down Expand Up @@ -632,7 +632,7 @@ func TestAttributeFilter(t *testing.T) {
wantMetric metricdata.Metrics
}{
{
name: "AsyncFloat64Counter",
name: "ObservableFloat64Counter",
register: func(t *testing.T, mtr metric.Meter) error {
ctr, err := mtr.Float64ObservableCounter("afcounter")
if err != nil {
Expand All @@ -659,7 +659,7 @@ func TestAttributeFilter(t *testing.T) {
},
},
{
name: "AsyncFloat64UpDownCounter",
name: "ObservableFloat64UpDownCounter",
register: func(t *testing.T, mtr metric.Meter) error {
ctr, err := mtr.Float64ObservableUpDownCounter("afupdowncounter")
if err != nil {
Expand All @@ -686,7 +686,7 @@ func TestAttributeFilter(t *testing.T) {
},
},
{
name: "AsyncFloat64Gauge",
name: "ObservableFloat64Gauge",
register: func(t *testing.T, mtr metric.Meter) error {
ctr, err := mtr.Float64ObservableGauge("afgauge")
if err != nil {
Expand All @@ -711,7 +711,7 @@ func TestAttributeFilter(t *testing.T) {
},
},
{
name: "AsyncInt64Counter",
name: "ObservableInt64Counter",
register: func(t *testing.T, mtr metric.Meter) error {
ctr, err := mtr.Int64ObservableCounter("aicounter")
if err != nil {
Expand All @@ -738,7 +738,7 @@ func TestAttributeFilter(t *testing.T) {
},
},
{
name: "AsyncInt64UpDownCounter",
name: "ObservableInt64UpDownCounter",
register: func(t *testing.T, mtr metric.Meter) error {
ctr, err := mtr.Int64ObservableUpDownCounter("aiupdowncounter")
if err != nil {
Expand All @@ -765,7 +765,7 @@ func TestAttributeFilter(t *testing.T) {
},
},
{
name: "AsyncInt64Gauge",
name: "ObservableInt64Gauge",
register: func(t *testing.T, mtr metric.Meter) error {
ctr, err := mtr.Int64ObservableGauge("aigauge")
if err != nil {
Expand Down Expand Up @@ -1006,13 +1006,13 @@ func BenchmarkInstrumentCreation(b *testing.B) {
b.ResetTimer()

for n := 0; n < b.N; n++ {
aiCounter, _ = meter.Int64ObservableCounter("async.int64.counter")
aiUpDownCounter, _ = meter.Int64ObservableUpDownCounter("async.int64.up.down.counter")
aiGauge, _ = meter.Int64ObservableGauge("async.int64.gauge")
aiCounter, _ = meter.Int64ObservableCounter("observable.int64.counter")
aiUpDownCounter, _ = meter.Int64ObservableUpDownCounter("observable.int64.up.down.counter")
aiGauge, _ = meter.Int64ObservableGauge("observable.int64.gauge")

afCounter, _ = meter.Float64ObservableCounter("async.float64.counter")
afUpDownCounter, _ = meter.Float64ObservableUpDownCounter("async.float64.up.down.counter")
afGauge, _ = meter.Float64ObservableGauge("async.float64.gauge")
afCounter, _ = meter.Float64ObservableCounter("observable.float64.counter")
afUpDownCounter, _ = meter.Float64ObservableUpDownCounter("observable.float64.up.down.counter")
afGauge, _ = meter.Float64ObservableGauge("observable.float64.gauge")

siCounter, _ = meter.Int64Counter("sync.int64.counter")
siUpDownCounter, _ = meter.Int64UpDownCounter("sync.int64.up.down.counter")
Expand Down
26 changes: 13 additions & 13 deletions sdk/metric/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ func (i *inserter[N]) instrumentID(kind InstrumentKind, stream Stream) instrumen
}

switch kind {
case InstrumentKindAsyncCounter, InstrumentKindSyncCounter, InstrumentKindSyncHistogram:
case InstrumentKindObservableCounter, InstrumentKindCounter, InstrumentKindHistogram:
id.Monotonic = true
}

Expand All @@ -350,7 +350,7 @@ func (i *inserter[N]) aggregator(agg aggregation.Aggregation, kind InstrumentKin
return internal.NewLastValue[N](), nil
case aggregation.Sum:
switch kind {
case InstrumentKindAsyncCounter, InstrumentKindAsyncUpDownCounter:
case InstrumentKindObservableCounter, InstrumentKindObservableUpDownCounter:
// Asynchronous counters and up-down-counters are defined to record
// the absolute value of the count:
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#asynchronous-counter-creation
Expand Down Expand Up @@ -388,34 +388,34 @@ func (i *inserter[N]) aggregator(agg aggregation.Aggregation, kind InstrumentKin
// isAggregatorCompatible checks if the aggregation can be used by the instrument.
// Current compatibility:
//
// | Instrument Kind | Drop | LastValue | Sum | Histogram | Exponential Histogram |
// |----------------------|------|-----------|-----|-----------|-----------------------|
// | Sync Counter | X | | X | X | X |
// | Sync UpDown Counter | X | | X | | |
// | Sync Histogram | X | | X | X | X |
// | Async Counter | X | | X | | |
// | Async UpDown Counter | X | | X | | |
// | Async Gauge | X | X | | | |.
// | Instrument Kind | Drop | LastValue | Sum | Histogram | Exponential Histogram |
// |--------------------------|------|-----------|-----|-----------|-----------------------|
// | Counter | X | | X | X | X |
// | UpDownCounter | X | | X | | |
// | Histogram | X | | X | X | X |
// | Observable Counter | X | | X | | |
// | Observable UpDownCounter | X | | X | | |
// | Observable Gauge | X | X | | | |.
func isAggregatorCompatible(kind InstrumentKind, agg aggregation.Aggregation) error {
switch agg.(type) {
case aggregation.ExplicitBucketHistogram:
if kind == InstrumentKindSyncCounter || kind == InstrumentKindSyncHistogram {
if kind == InstrumentKindCounter || kind == InstrumentKindHistogram {
return nil
}
// TODO: review need for aggregation check after
// https://github.com/open-telemetry/opentelemetry-specification/issues/2710
return errIncompatibleAggregation
case aggregation.Sum:
switch kind {
case InstrumentKindAsyncCounter, InstrumentKindAsyncUpDownCounter, InstrumentKindSyncCounter, InstrumentKindSyncHistogram, InstrumentKindSyncUpDownCounter:
case InstrumentKindObservableCounter, InstrumentKindObservableUpDownCounter, InstrumentKindCounter, InstrumentKindHistogram, InstrumentKindUpDownCounter:
return nil
default:
// TODO: review need for aggregation check after
// https://github.com/open-telemetry/opentelemetry-specification/issues/2710
return errIncompatibleAggregation
}
case aggregation.LastValue:
if kind == InstrumentKindAsyncGauge {
if kind == InstrumentKindObservableGauge {
return nil
}
// TODO: review need for aggregation check after
Expand Down
Loading

0 comments on commit 5d5859a

Please sign in to comment.