Sha256: 66ce8eb1c9bf36b50bbe9c97dc3646e838154fcb895c10cbc013be8e6bc9a95c

Contents?: true

Size: 1022 Bytes

Versions: 2

Compression:

Stored size: 1022 Bytes

Contents

require 'ndr_stats/version'

require 'ndr_stats/config'
require 'ndr_stats/ping'
require 'ndr_stats/railtie' if defined?(Rails)
require 'ndr_stats/stats'

# Code to allow instrumentation to be fed back to prometheus.
#
#   # Icrement a counter by one:
#   NdrStats.count('sheep', colour: 'black')
#   # Or by many:
#   NdrStats.count('rabbits', 10)
#
#   # Set a gauge:
#   NdrStats.gauge('active_daemons', 10)
#
#   # Time some code:
#   NdrStats.time('validation', class: 'Tumour') { @tumour.valid? }
#
module NdrStats
  extend Config
  extend Stats

  class << self
    attr_accessor :adaptor

    # Register some tags to update the :ping counter periodically.
    #
    #   # basic tagged ping:
    #   NdrStats.ping(type: 'webapp')

    #   # supply additional tags:
    #   NdrStats.ping(type: 'daemon', name: 'batch importer')

    #   # set a custom frequency (defaults to every minute):
    #   NdrStats.ping(type: 'sloth', every: 3.hours)
    #
    def ping(**args)
      Ping.register(**args)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ndr_stats-0.2.2 lib/ndr_stats.rb
ndr_stats-0.2.1 lib/ndr_stats.rb