diff options
author | Mike Greiling <mike@pixelcog.com> | 2018-01-31 14:06:25 -0600 |
---|---|---|
committer | Mike Greiling <mike@pixelcog.com> | 2018-01-31 14:06:25 -0600 |
commit | 3a565d5d3a0cc610ea0bd114125606bed6e4dc34 (patch) | |
tree | 1012e38a6efa6edf2f26b1acf17f94e8e38de6d1 /lib/gitlab/metrics/methods/metric_options.rb | |
parent | e25f383ddc6b867dc4010be10518d79c663d7409 (diff) | |
parent | 560c93e60efd0ae5a1a6bed68a1ee3e74bf23737 (diff) | |
download | gitlab-ce-3a565d5d3a0cc610ea0bd114125606bed6e4dc34.tar.gz |
Merge branch 'master' into pawel/connect_to_prometheus_through_proxy-30480
* master: (119 commits)
[ci skip] Fix example commands to refer to the correct versions
Use axios instead of jquery ajax for setCiStatusFavicon
refactor groups controller to match EE
Fix broken test
Introduce a new QA::Gitlab::Page::Component::Dropzone class
Gitaly Server info for admin panel
Add note about being in the `qa` directory for `bin/qa` to work
Remove N+1 queries with /projects/:project_id/{access_requests,members} API endpoints
Fix not all events being shown in group dashboard
Add support for PreReceiveError in UserMergeBranch RPC
Migrate Git::Repository#delete_refs to Gitaly
Replace $.get in render math with axios
Move mr widget related links into a vue file
Make those files as close as EE to reduce conflicts
Don't assume postgresql in two initializers
Move Repository#can_be_merged? to Gitlab::Git::Repository
Remove brakeman from .codeclimate.yml since it's now covered by the sast CI job
Update Nokogiri to 1.8.2
Ignore conflicts in db/schema.rb in Gitlab::EeCompatCheck
Remove Rugged exception in cache rescue
...
Diffstat (limited to 'lib/gitlab/metrics/methods/metric_options.rb')
-rw-r--r-- | lib/gitlab/metrics/methods/metric_options.rb | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/lib/gitlab/metrics/methods/metric_options.rb b/lib/gitlab/metrics/methods/metric_options.rb new file mode 100644 index 00000000000..70e122d4e15 --- /dev/null +++ b/lib/gitlab/metrics/methods/metric_options.rb @@ -0,0 +1,61 @@ +module Gitlab + module Metrics + module Methods + class MetricOptions + SMALL_NETWORK_BUCKETS = [0.005, 0.01, 0.1, 1, 10].freeze + + def initialize(options = {}) + @multiprocess_mode = options[:multiprocess_mode] || :all + @buckets = options[:buckets] || SMALL_NETWORK_BUCKETS + @base_labels = options[:base_labels] || {} + @docstring = options[:docstring] + @with_feature = options[:with_feature] + end + + # Documentation describing metric in metrics endpoint '/-/metrics' + def docstring(docstring = nil) + @docstring = docstring unless docstring.nil? + + @docstring + 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) + @multiprocess_mode = mode unless mode.nil? + + @multiprocess_mode + end + + # Measurement buckets for histograms + def buckets(buckets = nil) + @buckets = buckets unless buckets.nil? + + @buckets + end + + # Base labels are merged with per metric labels + def base_labels(base_labels = nil) + @base_labels = base_labels unless base_labels.nil? + + @base_labels + end + + # Use feature toggle to control whether certain metric is enabled/disabled + def with_feature(name = nil) + @with_feature = name unless name.nil? + + @with_feature + end + + def evaluate(&block) + instance_eval(&block) if block_given? + self + end + end + end + end +end |