Class: OpenTelemetry::Trace::Status
- Inherits:
-
Object
- Object
- OpenTelemetry::Trace::Status
- Defined in:
- lib/opentelemetry/trace/status.rb
Overview
Status represents the status of a finished Span. It is composed of a status code in conjunction with an optional descriptive message.
Constant Summary collapse
- OK =
The operation completed successfully.
0
- UNSET =
The default status.
1
- ERROR =
An error.
2
Instance Attribute Summary collapse
-
#code ⇒ Integer
readonly
Retrieve the status code of this Status.
-
#description ⇒ String
readonly
Retrieve the description of this Status.
Class Method Summary collapse
-
.error(description = '') ⇒ Status
Returns a newly created Status with code == ERROR and an optional description.
-
.ok(description = '') ⇒ Status
Returns a newly created Status with code == OK and an optional description.
-
.unset(description = '') ⇒ Status
Returns a newly created Status with code == UNSET and an optional description.
Instance Method Summary collapse
-
#initialize(code, description: '') ⇒ Status
constructor
private
The constructor is private and only for use internally by the class.
-
#ok? ⇒ Boolean
Returns false if this Status represents an error, else returns true.
Constructor Details
#initialize(code, description: '') ⇒ Status
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The constructor is private and only for use internally by the class. Users should use the unset, error, or ok factory methods to obtain a OpenTelemetry::Trace::Status instance.
60 61 62 63 |
# File 'lib/opentelemetry/trace/status.rb', line 60 def initialize(code, description: '') @code = code @description = description end |
Instance Attribute Details
#code ⇒ Integer (readonly)
Retrieve the status code of this Status.
46 47 48 |
# File 'lib/opentelemetry/trace/status.rb', line 46 def code @code end |
#description ⇒ String (readonly)
Retrieve the description of this Status.
51 52 53 |
# File 'lib/opentelemetry/trace/status.rb', line 51 def description @description end |
Class Method Details
.error(description = '') ⇒ Status
Returns a newly created OpenTelemetry::Trace::Status with code == ERROR and an optional description.
38 39 40 |
# File 'lib/opentelemetry/trace/status.rb', line 38 def error(description = '') new(ERROR, description: description) end |
.ok(description = '') ⇒ Status
Returns a newly created OpenTelemetry::Trace::Status with code == OK and an optional description.
29 30 31 |
# File 'lib/opentelemetry/trace/status.rb', line 29 def ok(description = '') new(OK, description: description) end |
.unset(description = '') ⇒ Status
Returns a newly created OpenTelemetry::Trace::Status with code == UNSET and an optional description.
20 21 22 |
# File 'lib/opentelemetry/trace/status.rb', line 20 def unset(description = '') new(UNSET, description: description) end |
Instance Method Details
#ok? ⇒ Boolean
Returns false if this OpenTelemetry::Trace::Status represents an error, else returns true.
68 69 70 |
# File 'lib/opentelemetry/trace/status.rb', line 68 def ok? @code != ERROR end |