blob: 1039bf40cdae120130354eb5d2f90af1b551c30f [file] [log] [blame]
Abhay Kumar40252eb2025-10-13 13:25:53 +00001// Copyright The OpenTelemetry Authors
2// SPDX-License-Identifier: Apache-2.0
3
4package 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
10type StatusCode int32
11
12const (
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
22var statusCodeStrings = []string{
23 "Unset",
24 "OK",
25 "Error",
26}
27
28func (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.
37type 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}