module Appsignal::Probes::Helpers

def gauge_delta(cache_key, value)


end
puts "this block will be yielded to with delta = #{delta}"
# `delta` has a value of `5`
gauge_delta :with_block, 15 do |delta|
end
puts "this block will not be yielded to"
gauge_delta :with_block, 10 do |delta|
@example

gauges.
This is used for absolute counter values which we want to track as

will be yielded to the block.
in the cache for that key and the value given in this invocation
In subsequent calls, the delta between the previously stored value
is called for a given cache key, the block will not be yielded to.
A block must be passed to this method. The first time the method

under the given cache key.
When this method is called, the given value is stored in a cache

Calculate the delta of two values for a gauge metric.
def gauge_delta(cache_key, value)
  previous_value = gauge_delta_cache[cache_key]
  gauge_delta_cache[cache_key] = value
  return unless previous_value
  yield value - previous_value
end

def gauge_delta_cache

def gauge_delta_cache
  @gauge_delta_cache ||= {}
end

def hostname

def hostname
  return @hostname if defined?(@hostname)
  config = @appsignal.config
  # Auto detect hostname as fallback. May be inaccurate.
  @hostname =
    config[:hostname] || Socket.gethostname
  Appsignal.internal_logger.debug "Probe helper: Using hostname config " \
    "option '#{@hostname.inspect}' as hostname"
  @hostname
end

def set_gauge_with_hostname(metric, value, tags = {})

def set_gauge_with_hostname(metric, value, tags = {})
  @appsignal.set_gauge(metric, value, { :hostname => hostname }.merge(tags))
end