Class: OpenTelemetry::Trace::Status

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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.

Parameters:

  • code (Integer)

    One of the status codes below

  • description (String) (defaults to: '')


60
61
62
63
# File 'lib/opentelemetry/trace/status.rb', line 60

def initialize(code, description: '')
  @code = code
  @description = description
end

Instance Attribute Details

#codeInteger (readonly)

Retrieve the status code of this Status.

Returns:

  • (Integer)


46
47
48
# File 'lib/opentelemetry/trace/status.rb', line 46

def code
  @code
end

#descriptionString (readonly)

Retrieve the description of this Status.

Returns:

  • (String)


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.

Parameters:

  • description (String) (defaults to: '')

Returns:



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.

Parameters:

  • description (String) (defaults to: '')

Returns:



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.

Parameters:

  • description (String) (defaults to: '')

Returns:



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.

Returns:

  • (Boolean)


68
69
70
# File 'lib/opentelemetry/trace/status.rb', line 68

def ok?
  @code != ERROR
end