lib/opentelemetry/trace/util/http_to_status.rb in opentelemetry-api-0.6.0 vs lib/opentelemetry/trace/util/http_to_status.rb in opentelemetry-api-0.7.0
- old
+ new
@@ -7,39 +7,20 @@
module OpenTelemetry
module Trace
module Util
# Convenience methods, not necessarily required by the API specification.
module HttpToStatus
- # Implemented according to
- # https://github.com/open-telemetry/opentelemetry-specification/issues/306
- # https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/data-http.md#status
+ # Maps numeric HTTP status codes to Trace::Status. This module is a mixin for Trace::Status
+ # and is not intended for standalone use.
#
# @param code Numeric HTTP status
# @return Status
- def http_to_status(code) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
+ def http_to_status(code)
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))
+ new(const_get(:ERROR))
end
end
end
end
end