[VOL-5486] Fix deprecated versions
Change-Id: I3e03ea246020547ae75fa92ce8cf5cbba7e8f3bb
Signed-off-by: Abhay Kumar <abhay.kumar@radisys.com>
diff --git a/vendor/go.opentelemetry.io/otel/codes/codes.go b/vendor/go.opentelemetry.io/otel/codes/codes.go
index 28393a5..49a35b1 100644
--- a/vendor/go.opentelemetry.io/otel/codes/codes.go
+++ b/vendor/go.opentelemetry.io/otel/codes/codes.go
@@ -1,24 +1,11 @@
// 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.
+// SPDX-License-Identifier: Apache-2.0
-// Package codes defines the canonical error codes used by OpenTelemetry.
-//
-// It conforms to [the OpenTelemetry
-// specification](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/api.md#statuscanonicalcode).
package codes // import "go.opentelemetry.io/otel/codes"
import (
+ "encoding/json"
+ "errors"
"fmt"
"strconv"
)
@@ -26,10 +13,20 @@
const (
// Unset is the default status code.
Unset Code = 0
+
// Error indicates the operation contains an error.
+ //
+ // NOTE: The error code in OTLP is 2.
+ // The value of this enum is only relevant to the internals
+ // of the Go SDK.
Error Code = 1
+
// Ok indicates operation has been validated by an Application developers
// or Operator to have completed successfully, or contain no error.
+ //
+ // NOTE: The Ok code in OTLP is 1.
+ // The value of this enum is only relevant to the internals
+ // of the Go SDK.
Ok Code = 2
maxCode = 3
@@ -45,9 +42,9 @@
}
var strToCode = map[string]Code{
- "Unset": Unset,
- "Error": Error,
- "Ok": Ok,
+ `"Unset"`: Unset,
+ `"Error"`: Error,
+ `"Ok"`: Ok,
}
// String returns the Code as a string.
@@ -67,23 +64,33 @@
return nil
}
if c == nil {
- return fmt.Errorf("nil receiver passed to UnmarshalJSON")
+ return errors.New("nil receiver passed to UnmarshalJSON")
}
- if ci, err := strconv.ParseUint(string(b), 10, 32); err == nil {
- if ci >= maxCode {
- return fmt.Errorf("invalid code: %q", ci)
+ var x interface{}
+ if err := json.Unmarshal(b, &x); err != nil {
+ return err
+ }
+ switch x.(type) {
+ case string:
+ if jc, ok := strToCode[string(b)]; ok {
+ *c = jc
+ return nil
}
+ return fmt.Errorf("invalid code: %q", string(b))
+ case float64:
+ if ci, err := strconv.ParseUint(string(b), 10, 32); err == nil {
+ if ci >= maxCode {
+ return fmt.Errorf("invalid code: %q", ci)
+ }
- *c = Code(ci)
- return nil
+ *c = Code(ci) // nolint: gosec // Bit size of 32 check above.
+ return nil
+ }
+ return fmt.Errorf("invalid code: %q", string(b))
+ default:
+ return fmt.Errorf("invalid code: %q", string(b))
}
-
- if jc, ok := strToCode[string(b)]; ok {
- *c = jc
- return nil
- }
- return fmt.Errorf("invalid code: %q", string(b))
}
// MarshalJSON returns c as the JSON encoding of c.