Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
juliusv committed Feb 3, 2017
1 parent 0ea6e4f commit d1b5795
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/prometheus/client/counter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def increment(labels = {}, by = 1)
private

def default(labels)
Prometheus::Client::ValueType.new(type, @name, @name, labels)
ValueType.new(type, @name, @name, labels)
end
end
end
Expand Down
8 changes: 8 additions & 0 deletions lib/prometheus/client/histogram.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ def observe(value)
self[bucket].increment() if value <= bucket
end
end

def get()
hash = {}
each_key do |bucket|
hash[bucket] = self[bucket].get()
end
hash
end
end

# DEFAULT_BUCKETS are the default Histogram buckets. The default buckets
Expand Down
3 changes: 2 additions & 1 deletion lib/prometheus/client/metric.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

require 'thread'
require 'prometheus/client/label_set_validator'
require 'prometheus/client/valuetype'

module Prometheus
module Client
Expand Down Expand Up @@ -42,7 +43,7 @@ def values
private

def default(labels)
ValueType.new(@name, @name, labels, nil)
ValueType.new(type, @name, @name, labels, nil)
end

def validate_name(name)
Expand Down
6 changes: 6 additions & 0 deletions spec/prometheus/client/formats/text_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# encoding: UTF-8

require 'prometheus/client/formats/text'
require 'prometheus/client/valuetype'

describe Prometheus::Client::Formats::Text do
let(:summary_value) do
Expand Down Expand Up @@ -65,6 +66,11 @@
},
),
]
metrics.each do |m|
m.values.each do |k, v|
m.values[k] = Prometheus::Client::ValueType.new(m.type, m.name, m.name, k, v)
end
end
double(metrics: metrics)
end

Expand Down

0 comments on commit d1b5795

Please sign in to comment.