Module: OpenTelemetry::Trace::Util::HttpToStatus

Included in:
Status
Defined in:
lib/opentelemetry/trace/util/http_to_status.rb

Overview

Convenience methods, not necessarily required by the API specification.

Instance Method Summary collapse

Instance Method Details

#http_to_status(code) ⇒ Object

Parameters:

  • code

    Numeric HTTP status

Returns:

  • Status



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/opentelemetry/trace/util/http_to_status.rb', line 18

def http_to_status(code) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
  case code.to_i
  when 100..399
    new(const_get(:OK))
  when 401
    new(const_get(:UNAUTHENTICATED))
  when 403
    new(const_get(:PERMISSION_DENIED))
  when 404
    new(const_get(:NOT_FOUND))
  when 429
    new(const_get(:RESOURCE_EXHAUSTED))
  when 400..499
    new(const_get(:INVALID_ARGUMENT))
  when 501
    new(const_get(:UNIMPLEMENTED))
  when 503
    new(const_get(:UNAVAILABLE))
  when 504
    new(const_get(:DEADLINE_EXCEEDED))
  when 500..599
    new(const_get(:INTERNAL_ERROR))
  else
    new(const_get(:UNKNOWN_ERROR))
  end
end