Commit 66c2a3a8 authored by Pawel Chojnacki's avatar Pawel Chojnacki

Fix helper methods and document metric builder options

parent 5328584b
...@@ -65,28 +65,28 @@ module Gitlab ...@@ -65,28 +65,28 @@ module Gitlab
# @param [Symbol] name # @param [Symbol] name
# @param [Hash] opts # @param [Hash] opts
def fetch_counter(name, opts = {}, &block) def fetch_counter(name, opts = {}, &block)
define_metric(:counter, name, opts, &block) fetch_metric(:counter, name, opts, &block)
end end
# DFetch and/or initialize gauge metric # DFetch and/or initialize gauge metric
# @param [Symbol] name # @param [Symbol] name
# @param [Hash] opts # @param [Hash] opts
def fetch_gauge(name, opts = {}, &block) def fetch_gauge(name, opts = {}, &block)
define_metric(:counter, name, opts, &block) fetch_metric(:counter, name, opts, &block)
end end
# Fetch and/or initialize histogram metric # Fetch and/or initialize histogram metric
# @param [Symbol] name # @param [Symbol] name
# @param [Hash] opts # @param [Hash] opts
def fetch_histogram(name, opts = {}, &block) def fetch_histogram(name, opts = {}, &block)
define_metric(:histogram, name, opts, &block) fetch_metric(:histogram, name, opts, &block)
end end
# Fetch and/or initialize summary metric # Fetch and/or initialize summary metric
# @param [Symbol] name # @param [Symbol] name
# @param [Hash] opts # @param [Hash] opts
def fetch_summary(name, opts = {}, &block) def fetch_summary(name, opts = {}, &block)
define_metric(:summary, name, opts, &block) fetch_metric(:summary, name, opts, &block)
end end
# Define metric accessor method for a Counter # Define metric accessor method for a Counter
......
...@@ -10,30 +10,39 @@ module Gitlab ...@@ -10,30 +10,39 @@ module Gitlab
@with_feature = options[:with_feature] @with_feature = options[:with_feature]
end end
# Documentation describing metric in metrics endpoint '/-/metrics'
def docstring(docstring = nil) def docstring(docstring = nil)
@docstring = docstring unless docstring.nil? @docstring = docstring unless docstring.nil?
@docstring @docstring
end end
# Gauge aggregation mode for multiprocess metrics
# - :all (default) returns each gauge for every process
# - :livesum all process'es gauges summed up
# - :max maximum value of per process gauges
# - :min minimum value of per process gauges
def multiprocess_mode(mode = nil) def multiprocess_mode(mode = nil)
@multiprocess_mode = mode unless mode.nil? @multiprocess_mode = mode unless mode.nil?
@multiprocess_mode @multiprocess_mode
end end
# Measurement buckets for histograms
def buckets(buckets = nil) def buckets(buckets = nil)
@buckets = buckets unless buckets.nil? @buckets = buckets unless buckets.nil?
@buckets @buckets
end end
# Base labels are merged with per metric labels
def base_labels(base_labels = nil) def base_labels(base_labels = nil)
@base_labels = base_labels unless base_labels.nil? @base_labels = base_labels unless base_labels.nil?
@base_labels @base_labels
end end
# Use feature toggle to control whether certain metric is enabled/disabled
def with_feature(name = nil) def with_feature(name = nil)
@feature_name = name unless name.nil? @feature_name = name unless name.nil?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment