Sha256: 25ff8d0cf035bf50fb0a8f05d7443688adb845e1e2b14a07befe1e62acdc2cfb

Contents?: true

Size: 748 Bytes

Versions: 14

Compression:

Stored size: 748 Bytes

Contents

require_relative "prometheus_exporter/version"
require "json"
require "thread"

module PrometheusExporter
  # per: https://github.com/prometheus/prometheus/wiki/Default-port-allocations
  DEFAULT_PORT = 9394
  DEFAULT_PREFIX = 'ruby_'
  DEFAULT_TIMEOUT = 2

  class OjCompat
    def self.parse(obj)
      Oj.compat_load(obj)
    end
    def self.dump(obj)
      Oj.dump(obj, mode: :compat)
    end
  end

  def self.detect_json_serializer(preferred)
    if preferred.nil?
      preferred = :oj if has_oj?
    end

    preferred == :oj ? OjCompat : JSON
  end

  @@has_oj = nil
  def self.has_oj?
    (
      @@has_oj ||=
       begin
         require 'oj'
         :true
       rescue LoadError
         :false
       end
    ) == :true
  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
prometheus_exporter-0.4.10 lib/prometheus_exporter.rb
prometheus_exporter-0.4.9 lib/prometheus_exporter.rb
prometheus_exporter-0.4.8 lib/prometheus_exporter.rb
prometheus_exporter-0.4.7 lib/prometheus_exporter.rb
prometheus_exporter-0.4.6 lib/prometheus_exporter.rb
prometheus_exporter-0.4.5 lib/prometheus_exporter.rb
prometheus_exporter-0.4.4 lib/prometheus_exporter.rb
prometheus_exporter-0.4.3 lib/prometheus_exporter.rb
prometheus_exporter-0.4.2 lib/prometheus_exporter.rb
prometheus_exporter-0.4.1 lib/prometheus_exporter.rb
prometheus_exporter-0.4.0 lib/prometheus_exporter.rb
prometheus_exporter-0.3.4 lib/prometheus_exporter.rb
prometheus_exporter-0.3.3 lib/prometheus_exporter.rb
prometheus_exporter-0.3.1 lib/prometheus_exporter.rb