Sha256: dbfaa0f3d06058906d868ce8ba8ef248aa17ac2514c19d335093cb43c62cac34

Contents?: true

Size: 713 Bytes

Versions: 9

Compression:

Stored size: 713 Bytes

Contents

# frozen_string_literal: true

# Copyright The OpenTelemetry Authors
#
# SPDX-License-Identifier: Apache-2.0

module OpenTelemetry
  module Trace
    module Util
      # Convenience methods, not necessarily required by the API specification.
      module HttpToStatus
        # 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)
          case code.to_i
          when 100..399
            new(const_get(:OK))
          else
            new(const_get(:ERROR))
          end
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
opentelemetry-api-1.0.0.rc1 lib/opentelemetry/trace/util/http_to_status.rb
opentelemetry-api-0.17.0 lib/opentelemetry/trace/util/http_to_status.rb
opentelemetry-api-0.16.0 lib/opentelemetry/trace/util/http_to_status.rb
opentelemetry-api-0.15.0 lib/opentelemetry/trace/util/http_to_status.rb
opentelemetry-api-0.14.0 lib/opentelemetry/trace/util/http_to_status.rb
opentelemetry-api-0.13.0 lib/opentelemetry/trace/util/http_to_status.rb
opentelemetry-api-0.12.1 lib/opentelemetry/trace/util/http_to_status.rb
opentelemetry-api-0.12.0 lib/opentelemetry/trace/util/http_to_status.rb
opentelemetry-api-0.11.0 lib/opentelemetry/trace/util/http_to_status.rb