Sha256: 2c458ea400eb06b5816fbf0bb25111035d99067fd75d855a8b88337dad7d6678

Contents?: true

Size: 714 Bytes

Versions: 4

Compression:

Stored size: 714 Bytes

Contents

# frozen_string_literal: true

# Copyright 2019 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

4 entries across 4 versions & 1 rubygems

Version Path
opentelemetry-api-0.10.0 lib/opentelemetry/trace/util/http_to_status.rb
opentelemetry-api-0.9.0 lib/opentelemetry/trace/util/http_to_status.rb
opentelemetry-api-0.8.0 lib/opentelemetry/trace/util/http_to_status.rb
opentelemetry-api-0.7.0 lib/opentelemetry/trace/util/http_to_status.rb