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