...

Package codes

import "go.opentelemetry.io/otel/codes"
Overview
Index

Overview ▾

Package codes defines the canonical error codes used by OpenTelemetry.

It conforms to [the OpenTelemetry specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.20.0/specification/trace/api.md#set-status).

type Code

Code is an 32-bit representation of a status state.

type Code uint32
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
)

func (*Code) MarshalJSON

func (c *Code) MarshalJSON() ([]byte, error)

MarshalJSON returns c as the JSON encoding of c.

func (Code) String

func (c Code) String() string

String returns the Code as a string.

func (*Code) UnmarshalJSON

func (c *Code) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals b into the Code.

This is based on the functionality in the gRPC codes package: https://github.com/grpc/grpc-go/blob/bb64fee312b46ebee26be43364a7a966033521b1/codes/codes.go#L218-L244