| 1 |
// Copyright The OpenTelemetry Authors |
| 2 |
// SPDX-License-Identifier: Apache-2.0 |
| 3 |
|
| 4 |
package telemetry // import "go.opentelemetry.io/otel/trace/internal/telemetry" |
| 5 |
|
| 6 |
// StatusCode is the status of a Span. |
| 7 |
// |
| 8 |
// For the semantics of status codes see |
| 9 |
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#set-status |
| 10 |
type StatusCode int32 |
| 11 |
|
| 12 |
const ( |
| 13 |
// StatusCodeUnset is the default status. |
| 14 |
StatusCodeUnset StatusCode = 0 |
| 15 |
// StatusCodeOK is used when the Span has been validated by an Application |
| 16 |
// developer or Operator to have completed successfully. |
| 17 |
StatusCodeOK StatusCode = 1 |
| 18 |
// StatusCodeError is used when the Span contains an error. |
| 19 |
StatusCodeError StatusCode = 2 |
| 20 |
) |
| 21 |
|
| 22 |
var statusCodeStrings = []string{ |
| 23 |
"Unset", |
| 24 |
"OK", |
| 25 |
"Error", |
| 26 |
} |
| 27 |
|
| 28 |
func (s StatusCode) String() string { |
| 29 |
if s >= 0 && int(s) < len(statusCodeStrings) { |
| 30 |
return statusCodeStrings[s] |
| 31 |
} |
| 32 |
return "<unknown telemetry.StatusCode>" |
| 33 |
} |
| 34 |
|
| 35 |
// Status defines a logical error model that is suitable for different |
| 36 |
// programming environments, including REST APIs and RPC APIs. |
| 37 |
type Status struct { |
| 38 |
// A developer-facing human readable error message. |
| 39 |
Message string `json:"message,omitempty"` |
| 40 |
// The status code. |
| 41 |
Code StatusCode `json:"code,omitempty"` |
| 42 |
} |