Add api/oterror package
This commit is contained in:
parent
3b76c770cc
commit
7cccff7944
|
|
@ -16,9 +16,9 @@ package metric
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
|
|
||||||
"go.opentelemetry.io/otel/api/kv"
|
"go.opentelemetry.io/otel/api/kv"
|
||||||
|
"go.opentelemetry.io/otel/api/oterror"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Measurement is used for reporting a synchronous batch of metric
|
// Measurement is used for reporting a synchronous batch of metric
|
||||||
|
|
@ -45,10 +45,6 @@ type asyncInstrument struct {
|
||||||
instrument AsyncImpl
|
instrument AsyncImpl
|
||||||
}
|
}
|
||||||
|
|
||||||
// ErrSDKReturnedNilImpl is used when one of the `MeterImpl` New
|
|
||||||
// methods returns nil.
|
|
||||||
var ErrSDKReturnedNilImpl = errors.New("SDK returned a nil implementation")
|
|
||||||
|
|
||||||
// SyncImpl returns the instrument that created this measurement.
|
// SyncImpl returns the instrument that created this measurement.
|
||||||
// This returns an implementation-level object for use by the SDK,
|
// This returns an implementation-level object for use by the SDK,
|
||||||
// users should not refer to this.
|
// users should not refer to this.
|
||||||
|
|
@ -114,7 +110,7 @@ func (h syncBoundInstrument) Unbind() {
|
||||||
func checkNewAsync(instrument AsyncImpl, err error) (asyncInstrument, error) {
|
func checkNewAsync(instrument AsyncImpl, err error) (asyncInstrument, error) {
|
||||||
if instrument == nil {
|
if instrument == nil {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = ErrSDKReturnedNilImpl
|
err = oterror.SDKReturnedNilImpl
|
||||||
}
|
}
|
||||||
instrument = NoopAsync{}
|
instrument = NoopAsync{}
|
||||||
}
|
}
|
||||||
|
|
@ -129,7 +125,7 @@ func checkNewAsync(instrument AsyncImpl, err error) (asyncInstrument, error) {
|
||||||
func checkNewSync(instrument SyncImpl, err error) (syncInstrument, error) {
|
func checkNewSync(instrument SyncImpl, err error) (syncInstrument, error) {
|
||||||
if instrument == nil {
|
if instrument == nil {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = ErrSDKReturnedNilImpl
|
err = oterror.SDKReturnedNilImpl
|
||||||
}
|
}
|
||||||
// Note: an alternate behavior would be to synthesize a new name
|
// Note: an alternate behavior would be to synthesize a new name
|
||||||
// or group all duplicately-named instruments of a certain type
|
// or group all duplicately-named instruments of a certain type
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
// Copyright The OpenTelemetry Authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The oterror package provides unified error interactions in OpenTelemetry.
|
||||||
|
* This includes providing standardized errors common to OpenTelemetry (APIs,
|
||||||
|
* SDKs, and exporters). Additionally it provides an API for unified error
|
||||||
|
* handling in OpenTelemetry.
|
||||||
|
*
|
||||||
|
* The unified error handling interface is used for any error that
|
||||||
|
* OpenTelemetry component are not able to remediate on their own, instead
|
||||||
|
* handeling them in a uniform and user-defined way.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package oterror
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
// Copyright The OpenTelemetry Authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package oterror
|
||||||
|
|
||||||
|
import "errors"
|
||||||
|
|
||||||
|
var (
|
||||||
|
// SDKReturnedNilImpl is returned when a new `MeterImpl` returns nil.
|
||||||
|
SDKReturnedNilImpl = errors.New("SDK returned a nil implementation")
|
||||||
|
)
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
// Copyright The OpenTelemetry Authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package oterror
|
||||||
|
|
||||||
|
// Handler performs a required function when an irremediable event is
|
||||||
|
// encountered.
|
||||||
|
type Handler interface {
|
||||||
|
// Error handles any error that irremediable by an OpenTelemetry
|
||||||
|
// component.
|
||||||
|
Error(error)
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue