status.go 1.1 KB

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