mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-01-26 03:52:03 +02:00
efd4e3a383
* Add otel/codes package to replace google.golang.org/grpc/codes * Replace google.golang.org/grpc/codes with otel/codes * Update opentracing bridge to use OTel codes * Update semconv to use OTel codes * Update SDK to convert from OTel codes to gRPC * go mod tidy * Add change to CHANGELOG * Fix word from feedback
50 lines
2.0 KiB
Go
50 lines
2.0 KiB
Go
// 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 internal
|
|
|
|
import (
|
|
grpccodes "google.golang.org/grpc/codes"
|
|
|
|
otelcodes "go.opentelemetry.io/otel/codes"
|
|
)
|
|
|
|
// conversions are the equivalence mapping from OpenTelemetry to gRPC codes.
|
|
// Even though the underlying value should be the same all mappings are
|
|
// explicit here to avoid any error.
|
|
var conversions = map[otelcodes.Code]grpccodes.Code{
|
|
otelcodes.OK: grpccodes.OK,
|
|
otelcodes.Canceled: grpccodes.Canceled,
|
|
otelcodes.Unknown: grpccodes.Unknown,
|
|
otelcodes.InvalidArgument: grpccodes.InvalidArgument,
|
|
otelcodes.DeadlineExceeded: grpccodes.DeadlineExceeded,
|
|
otelcodes.NotFound: grpccodes.NotFound,
|
|
otelcodes.AlreadyExists: grpccodes.AlreadyExists,
|
|
otelcodes.PermissionDenied: grpccodes.PermissionDenied,
|
|
otelcodes.ResourceExhausted: grpccodes.ResourceExhausted,
|
|
otelcodes.FailedPrecondition: grpccodes.FailedPrecondition,
|
|
otelcodes.Aborted: grpccodes.Aborted,
|
|
otelcodes.OutOfRange: grpccodes.OutOfRange,
|
|
otelcodes.Unimplemented: grpccodes.Unimplemented,
|
|
otelcodes.Internal: grpccodes.Internal,
|
|
otelcodes.Unavailable: grpccodes.Unavailable,
|
|
otelcodes.DataLoss: grpccodes.DataLoss,
|
|
otelcodes.Unauthenticated: grpccodes.Unauthenticated,
|
|
}
|
|
|
|
// ConvertCode converts an OpenTelemetry Code into the equivalent gRPC code.
|
|
func ConvertCode(code otelcodes.Code) grpccodes.Code {
|
|
return conversions[code]
|
|
}
|