promenade 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa72a557cfa72b79c12ff7990482904030bafa8cc1e5f1539d657b00e8a39d42
4
- data.tar.gz: 291a376f071a9e79cc00b812350ae1e6ad47f0a628481c653732c7c6357db2ea
3
+ metadata.gz: f7623122f1e7054e684064826e995acb44df8d056574b2c942a91d033d0a996a
4
+ data.tar.gz: 6da50efcc35f572b65a8bb0d85380442cdaa7529f8250efc00386ad2a0eb6267
5
5
  SHA512:
6
- metadata.gz: cb99059452e3faa5253c4d04bef70331a4853a7a7f567265e52ef2639931db386a2ec67a3420b1331d6f98b841e3c865d35d183f9afa7022c87768e87820c9ed
7
- data.tar.gz: 0cba0b9a5be3e357faac9ffd05bffbfe5b27a7d7cd0c2b7b7119a9c6ee43ecaad738162fb6fd6b8f669eb9e74b7c69319e48121cd4280fba1b893f14bcffd5c6
6
+ metadata.gz: 7bd6eb7ade6531acfbabb050c7d93986a9af727256f02afaef949146c286ea70a54ea6039eb48a18c60aa5662610111557db83ef2ab653ae3ba93436e6eb72c8
7
+ data.tar.gz: bf642c2d8e698be5d6d01b827472a1fbc65c7c6eb1db6ba5094e266b53339155b94454c73d1f0a3406b8fe9153728186d931c5cc16d79ff568ee377a92b60e53
data/.gitignore CHANGED
@@ -6,6 +6,7 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ .rubocop-https*yml
9
10
 
10
11
  # rspec failure tracking
11
12
  .rspec_status
data/.rubocop.yml ADDED
@@ -0,0 +1,10 @@
1
+ inherit_from:
2
+ - https://raw.githubusercontent.com/cookpad/guides/master/.rubocop.yml
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 2.4
6
+
7
+ Style/TrailingCommaInHashLiteral:
8
+ EnforcedStyleForMultiline: comma
9
+ Style/TrailingCommaInArguments:
10
+ EnforcedStyleForMultiline: comma
data/Gemfile CHANGED
@@ -1,6 +1,4 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
-
5
3
  # Specify your gem's dependencies in promenade.gemspec
6
4
  gemspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- promenade (0.1.0)
4
+ promenade (0.1.1)
5
5
  activesupport
6
6
  prometheus-client-mmap (~> 0.9.3)
7
7
 
@@ -13,14 +13,21 @@ GEM
13
13
  i18n (>= 0.7, < 2)
14
14
  minitest (~> 5.1)
15
15
  tzinfo (~> 1.1)
16
+ ast (2.4.0)
16
17
  concurrent-ruby (1.0.5)
17
18
  diff-lcs (1.3)
18
19
  docile (1.3.1)
19
20
  i18n (1.0.1)
20
21
  concurrent-ruby (~> 1.0)
22
+ jaro_winkler (1.5.1)
21
23
  json (2.1.0)
22
24
  minitest (5.11.3)
25
+ parallel (1.12.1)
26
+ parser (2.5.1.0)
27
+ ast (~> 2.4.0)
28
+ powerpack (0.1.2)
23
29
  prometheus-client-mmap (0.9.3)
30
+ rainbow (3.0.0)
24
31
  rake (10.5.0)
25
32
  rspec (3.7.0)
26
33
  rspec-core (~> 3.7.0)
@@ -35,6 +42,15 @@ GEM
35
42
  diff-lcs (>= 1.2.0, < 2.0)
36
43
  rspec-support (~> 3.7.0)
37
44
  rspec-support (3.7.1)
45
+ rubocop (0.57.2)
46
+ jaro_winkler (~> 1.5.1)
47
+ parallel (~> 1.10)
48
+ parser (>= 2.5)
49
+ powerpack (~> 0.1)
50
+ rainbow (>= 2.2.2, < 4.0)
51
+ ruby-progressbar (~> 1.7)
52
+ unicode-display_width (~> 1.0, >= 1.0.1)
53
+ ruby-progressbar (1.9.0)
38
54
  simplecov (0.16.1)
39
55
  docile (~> 1.1)
40
56
  json (>= 1.8, < 3)
@@ -43,6 +59,7 @@ GEM
43
59
  thread_safe (0.3.6)
44
60
  tzinfo (1.2.5)
45
61
  thread_safe (~> 0.1)
62
+ unicode-display_width (1.4.0)
46
63
 
47
64
  PLATFORMS
48
65
  ruby
@@ -52,6 +69,7 @@ DEPENDENCIES
52
69
  promenade!
53
70
  rake (~> 10.0)
54
71
  rspec (~> 3.0)
72
+ rubocop
55
73
  simplecov
56
74
 
57
75
  BUNDLED WITH
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Promenade
2
2
 
3
+ [![Build Status](https://travis-ci.org/errm/promenade.svg?branch=master)](https://travis-ci.org/errm/promenade)
4
+ [![Gem Version](https://badge.fury.io/rb/promenade.svg)](https://badge.fury.io/rb/promenade)
5
+
3
6
  Promenade is a libary to simplify instrumenting Ruby applications with prometheus.
4
7
 
5
8
  It is currently under development.
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
+ require "rubocop/rake_task"
3
4
 
4
5
  RSpec::Core::RakeTask.new(:spec)
6
+ RuboCop::RakeTask.new
5
7
 
6
- task :default => :spec
8
+ task default: %i(spec rubocop)
@@ -5,7 +5,7 @@ module Promenade
5
5
  extend ActiveSupport::Concern
6
6
 
7
7
  class_methods do
8
- %i[gauge counter summary, histogram].each do |type|
8
+ %i(gauge counter summary histogram).each do |type|
9
9
  define_method type do |*args, &block|
10
10
  Promenade::Prometheus.define_metric(type, *args, &block)
11
11
  end
@@ -0,0 +1,51 @@
1
+ require "promenade/kafka/subscriber"
2
+
3
+ module Promenade
4
+ module Kafka
5
+ class AsyncProducerSubscriber < Subscriber
6
+ attach_to "async_producer.kafka"
7
+
8
+ gauge :kafka_async_producer_queue_size do
9
+ doc "Size of Kafka async producer queue"
10
+ end
11
+
12
+ gauge :kafka_async_producer_max_queue_size do
13
+ doc "Max size of Kafka async producer queue"
14
+ end
15
+
16
+ gauge :kafka_async_producer_queue_fill_ratio do
17
+ doc "Size of Kafka async producer queue"
18
+ end
19
+
20
+ counter :kafka_async_producer_buffer_overflows do
21
+ doc "Count of buffer overflows"
22
+ end
23
+
24
+ counter :kafka_async_producer_dropped_messages do
25
+ doc "Count of dropped messages"
26
+ end
27
+
28
+ def enqueue_message(event)
29
+ labels = get_labels(event)
30
+ queue_size = event.payload.fetch(:queue_size)
31
+ max_queue_size = event.payload.fetch(:max_queue_size)
32
+ queue_fill_ratio = queue_size.to_f / max_queue_size.to_f
33
+
34
+ metric(:kafka_async_producer_queue_size).set(labels, queue_size)
35
+ metric(:kafka_async_producer_max_queue_size).set(labels, max_queue_size)
36
+ metric(:kafka_async_producer_queue_fill_ratio).set(labels, queue_fill_ratio)
37
+ end
38
+
39
+ def buffer_overflow(event)
40
+ metric(:kafka_async_producer_buffer_overflows).increment(get_labels(event))
41
+ end
42
+
43
+ def drop_messages(event)
44
+ client = event.payload.fetch(:client_id)
45
+ message_count = event.payload.fetch(:message_count)
46
+
47
+ metric(:kafka_async_producer_dropped_messages).increment({ client: client }, message_count)
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,47 @@
1
+ require "promenade/kafka/subscriber"
2
+
3
+ module Promenade
4
+ module Kafka
5
+ class ConnectionSubscriber < Subscriber
6
+ attach_to "connection.kafka"
7
+
8
+ histogram :kafka_connection_latency do
9
+ doc "Request latency"
10
+ buckets :network
11
+ end
12
+
13
+ counter :kafka_connection_calls do
14
+ doc "Count of calls made to Kafka broker"
15
+ end
16
+
17
+ summary :kafka_connection_request_size do
18
+ doc "Average size of requests made to kafka"
19
+ end
20
+
21
+ summary :kafka_connection_response_size do
22
+ doc "Average size of responses made by kafka"
23
+ end
24
+
25
+ histogram :kafka_connection_errors do
26
+ doc "Count of Kafka connection errors"
27
+ buckets :memory
28
+ end
29
+
30
+ def request(event) # rubocop:disable Metrics/AbcSize
31
+ labels = {
32
+ client: event.payload.fetch(:client_id),
33
+ api: event.payload.fetch(:api, "unknown"),
34
+ broker: event.payload.fetch(:broker_host),
35
+ }
36
+
37
+ metric(:kafka_connection_calls).increment(labels)
38
+ metric(:kafka_connection_latency).observe(labels, event.duration)
39
+
40
+ metric(:kafka_connection_request_size).observe(labels, event.payload.fetch(:request_size, 0))
41
+ metric(:kafka_connection_response_size).observe(labels, event.payload.fetch(:response_size, 0))
42
+
43
+ metric(:kafka_connection_errors).increment if event.payload.key?(:exception)
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,145 @@
1
+ require "promenade/kafka/subscriber"
2
+
3
+ module Promenade
4
+ module Kafka
5
+ class ConsumerSubscriber < Subscriber
6
+ attach_to "consumer.kafka"
7
+
8
+ gauge :kafka_consumer_time_lag do
9
+ doc "Lag between message create and consume time"
10
+ end
11
+
12
+ gauge :kafka_consumer_ofset_lag do
13
+ doc "Lag between message create and consume time"
14
+ end
15
+
16
+ histogram :kafka_consumer_message_processing_latency do
17
+ doc "Consumer message processing latency"
18
+ buckets :network
19
+ end
20
+
21
+ counter :kafka_consumer_messages_processed do
22
+ doc "Messages processed by this consumer"
23
+ end
24
+
25
+ counter :kafka_consumer_message_processing_errors do
26
+ doc "Consumer errors while processing a message"
27
+ end
28
+
29
+ histogram :kafka_consumer_batch_processing_latency do
30
+ doc "Consumer batch processing latency"
31
+ buckets :network
32
+ end
33
+
34
+ counter :kafka_consumer_batch_processing_errors do
35
+ doc "Consumer errors while processing a batch"
36
+ end
37
+
38
+ histogram :kafka_consumer_join_group do
39
+ doc "Time taken to join"
40
+ buckets :network
41
+ end
42
+
43
+ counter :kafka_consumer_join_group_errors do
44
+ doc "Errors joining the group"
45
+ end
46
+
47
+ histogram :kafka_consumer_sync_group do
48
+ doc "Time taken to sync"
49
+ buckets :network
50
+ end
51
+
52
+ counter :kafka_consumer_sync_group_errors do
53
+ doc "Errors syncing the group"
54
+ end
55
+
56
+ histogram :kafka_consumer_leave_group do
57
+ doc "Time taken to leave group"
58
+ buckets :network
59
+ end
60
+
61
+ counter :kafka_consumer_leave_group_errors do
62
+ doc "Errors leaving the group"
63
+ end
64
+
65
+ histogram :kafka_consumer_pause_duration do
66
+ doc "Time taken to leave group"
67
+ buckets :network
68
+ end
69
+
70
+ def process_message(event) # rubocop:disable Metrics/AbcSize
71
+ labels = get_labels(event)
72
+ offset_lag = event.payload.fetch(:offset_lag)
73
+ create_time = event.payload.fetch(:create_time)
74
+ time_lag = create_time && ((Time.now.utc - create_time) * 1000).to_i
75
+
76
+ if event.payload.key?(:exception)
77
+ metric(:kafka_consumer_message_processing_errors).increment(labels)
78
+ else
79
+ metric(:kafka_consumer_messages_processed).increment(labels)
80
+ metric(:kafka_consumer_message_processing_latency).observe(labels, event.duration)
81
+ end
82
+
83
+ metric(:kafka_consumer_ofset_lag).set(labels, offset_lag)
84
+
85
+ # Not all messages have timestamps.
86
+ metric(:kafka_consumer_time_lag).set(labels, time_lag) if time_lag
87
+ end
88
+
89
+ def process_batch(event) # rubocop:disable Metrics/AbcSize
90
+ labels = get_labels(event)
91
+ lag = event.payload.fetch(:offset_lag)
92
+ messages = event.payload.fetch(:message_count)
93
+
94
+ if event.payload.key?(:exception)
95
+ metric(:kafka_consumer_batch_processing_errors).increment(labels)
96
+ else
97
+ metric(:kafka_consumer_messages_processed).increment(labels, messages)
98
+ metric(:kafka_consumer_batch_processing_latency).observe(labels, event.duration)
99
+ end
100
+
101
+ metric(:kafka_consumer_ofset_lag).set(labels, lag)
102
+ end
103
+
104
+ def join_group(event)
105
+ labels = group_labels(event)
106
+ metric(:kafka_consumer_join_group).observe(labels, event.duration)
107
+ metric(:kafka_consumer_join_group_errors).increment(labels) if event.payload.key?(:exception)
108
+ end
109
+
110
+ def sync_group(event)
111
+ labels = group_labels(event)
112
+ metric(:kafka_consumer_sync_group).observe(labels, event.duration)
113
+ metric(:kafka_consumer_sync_group_errors).increment(labels) if event.payload.key?(:exception)
114
+ end
115
+
116
+ def leave_group(event)
117
+ labels = group_labels(event)
118
+ metric(:kafka_consumer_leave_group).observe(labels, event.duration)
119
+ metric(:kafka_consumer_leave_group_errors).increment(labels) if event.payload.key?(:exception)
120
+ end
121
+
122
+ def pause_status(event)
123
+ metric(:kafka_consumer_pause_duration).observe(get_labels(event), event.payload.fetch(:duration))
124
+ end
125
+
126
+ private
127
+
128
+ def get_labels(event)
129
+ {
130
+ client: event.payload.fetch(:client_id),
131
+ group: event.payload.fetch(:group_id),
132
+ topic: event.payload.fetch(:topic),
133
+ partition: event.payload.fetch(:partition),
134
+ }
135
+ end
136
+
137
+ def group_labels(event)
138
+ {
139
+ client: event.payload.fetch(:client_id),
140
+ group: event.payload.fetch(:group_id),
141
+ }
142
+ end
143
+ end
144
+ end
145
+ end
@@ -0,0 +1,21 @@
1
+ require "promenade/kafka/subscriber"
2
+
3
+ module Promenade
4
+ module Kafka
5
+ class FetcherSubscriber < Subscriber
6
+ attach_to "fetcher.kafka"
7
+
8
+ gauge :kafka_fetcher_queue_size do
9
+ doc "Fetcher queue size"
10
+ end
11
+
12
+ def loop(event)
13
+ queue_size = event.payload.fetch(:queue_size)
14
+ client = event.payload.fetch(:client_id)
15
+ group_id = event.payload.fetch(:group_id)
16
+
17
+ metric(:kafka_fetcher_queue_size).set({ client: client, group: group_id }, queue_size)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,117 @@
1
+ require "promenade/kafka/subscriber"
2
+
3
+ module Promenade
4
+ module Kafka
5
+ class ProducerSubscriber < Subscriber
6
+ attach_to "producer.kafka"
7
+
8
+ counter :kafka_producer_messages do
9
+ doc "Number of messages written to Kafka producer"
10
+ end
11
+
12
+ histogram :kafka_producer_message_size do
13
+ doc "Historgram of message sizes written to Kafka producer"
14
+ buckets :memory
15
+ end
16
+
17
+ gauge :kafka_producer_buffer_size do
18
+ doc "The current size of the Kafka producer buffer, in messages"
19
+ end
20
+
21
+ gauge :kafka_producer_max_buffer_size do
22
+ doc "The max size of the Kafka producer buffer"
23
+ end
24
+
25
+ gauge :kafka_producer_buffer_fill_ratio do
26
+ doc "The current ratio of Kafka producer buffer in use"
27
+ end
28
+
29
+ counter :kafka_producer_buffer_overflows do
30
+ doc "A count of kafka producer buffer overflow errors"
31
+ end
32
+
33
+ counter :kafka_producer_delivery_errors do
34
+ doc "A count of kafka producer delivery errors"
35
+ end
36
+
37
+ histogram :kafka_producer_delivery_latency do
38
+ doc "Kafka producer delivery latency histogram"
39
+ buckets :network
40
+ end
41
+
42
+ counter :kafka_producer_delivered_messages do
43
+ doc "A count of the total messages delivered to Kafka"
44
+ end
45
+
46
+ histogram :kafka_producer_delivery_attempts do
47
+ doc "A count of the total message deliveries attempted"
48
+ buckets [0, 6, 12, 18, 24, 30]
49
+ end
50
+
51
+ counter :kafka_producer_ack_messages do
52
+ doc "Count of the number of messages Acked by Kafka"
53
+ end
54
+
55
+ histogram :kafka_producer_ack_latency do
56
+ doc "Delay between message being produced and Acked"
57
+ buckets :network
58
+ end
59
+
60
+ counter :kafka_producer_ack_errors do
61
+ doc "Count of the number of Kafka Ack errors"
62
+ end
63
+
64
+ def produce_message(event) # rubocop:disable Metrics/AbcSize
65
+ labels = get_labels(event)
66
+ message_size = event.payload.fetch(:message_size)
67
+ buffer_size = event.payload.fetch(:buffer_size)
68
+ max_buffer_size = event.payload.fetch(:max_buffer_size)
69
+ buffer_fill_ratio = buffer_size.to_f / max_buffer_size.to_f
70
+
71
+ metric(:kafka_producer_messages).increment(labels)
72
+ metric(:kafka_producer_message_size).observe(labels, message_size)
73
+ metric(:kafka_producer_buffer_size).set(labels.slice(:client), buffer_size)
74
+ metric(:kafka_producer_max_buffer_size).set(labels.slice(:client), max_buffer_size)
75
+ metric(:kafka_producer_buffer_fill_ratio).set(labels.slice(:client), buffer_fill_ratio)
76
+ end
77
+
78
+ def buffer_overflow(event)
79
+ metric(:kafka_producer_buffer_overflows).increment(get_labels(event))
80
+ end
81
+
82
+ def deliver_messages(event) # rubocop:disable Metrics/AbcSize
83
+ labels = { client: event.payload.fetch(:client_id) }
84
+ message_count = event.payload.fetch(:delivered_message_count)
85
+ attempts = event.payload.fetch(:attempts)
86
+
87
+ metric(:kafka_producer_delivery_errors).increment(labels) if event.payload.key?(:exception)
88
+ metric(:kafka_producer_delivery_latency).observe(labels, event.duration)
89
+ metric(:kafka_producer_delivered_messages).increment(labels, message_count)
90
+ metric(:kafka_producer_delivery_attempts).observe(labels, attempts)
91
+ end
92
+
93
+ def ack_message(event)
94
+ labels = get_labels(event)
95
+ delay = event.payload.fetch(:delay)
96
+
97
+ metric(:kafka_producer_ack_messages).increment(labels)
98
+ metric(:kafka_producer_ack_latency).observe(labels, delay)
99
+ end
100
+
101
+ def topic_error(event)
102
+ client = event.payload.fetch(:client_id)
103
+ topic = event.payload.fetch(:topic)
104
+
105
+ metric(:kafka_producer_ack_errors).increment(client: client, topic: topic)
106
+ end
107
+
108
+ private
109
+
110
+ def get_labels(event)
111
+ client = event.payload.fetch(:client_id)
112
+ topic = event.payload.fetch(:topic)
113
+ { client: client, topic: topic }
114
+ end
115
+ end
116
+ end
117
+ end
@@ -0,0 +1,18 @@
1
+ require "promenade/helper"
2
+ require "active_support/subscriber"
3
+
4
+ module Promenade
5
+ module Kafka
6
+ class Subscriber < ActiveSupport::Subscriber
7
+ include ::Promenade::Helper
8
+
9
+ private
10
+
11
+ def get_labels(event)
12
+ client = event.payload.fetch(:client_id)
13
+ topic = event.payload.fetch(:topic)
14
+ { client: client, topic: topic }
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,5 @@
1
+ require "promenade/kafka/async_producer_subscriber"
2
+ require "promenade/kafka/connection_subscriber"
3
+ require "promenade/kafka/consumer_subscriber"
4
+ require "promenade/kafka/fetcher_subscriber"
5
+ require "promenade/kafka/producer_subscriber"
@@ -25,68 +25,62 @@ module Promenade
25
25
  end
26
26
 
27
27
  def self.registry
28
- @_registry ||= begin
29
- REGISTRY_MUTEX.synchronize do
30
- ::Prometheus::Client.registry
31
- end
32
- end
33
- end
34
-
35
- def self.reset!
36
- @_registry = nil
37
- ::Prometheus::Client.reset!
28
+ REGISTRY_MUTEX.synchronize do
29
+ @_registry ||= ::Prometheus::Client.registry
30
+ end
38
31
  end
39
- end
40
32
 
41
- class Options
42
- BUCKET_PRESETS = {
43
- network: [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10].freeze,
44
- }.freeze
33
+ class Options
34
+ BUCKET_PRESETS = {
35
+ network: [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10].freeze,
36
+ memory: (0..10).map { |i| 128 * 2**i },
37
+ }.freeze
45
38
 
46
- def initialize
47
- @buckets = BUCKET_PRESETS[:network]
48
- @base_labels = {}
49
- @doc = nil
50
- @multiprocess_mode = :all
51
- end
39
+ def initialize
40
+ @buckets = BUCKET_PRESETS[:network]
41
+ @base_labels = {}
42
+ @doc = nil
43
+ @multiprocess_mode = :all
44
+ end
52
45
 
53
- def doc(str)
54
- @doc = str
55
- end
46
+ def doc(str)
47
+ @doc = str
48
+ end
56
49
 
57
- def base_labels(labels)
58
- @base_labels = labels
59
- end
50
+ def base_labels(labels)
51
+ @base_labels = labels
52
+ end
60
53
 
61
- def multiprocess_mode(mode)
62
- @multiprocess_mode = mode
63
- end
54
+ def multiprocess_mode(mode)
55
+ @multiprocess_mode = mode
56
+ end
64
57
 
65
- def buckets(buckets)
66
- if buckets.is_a?(Symbol)
67
- @buckets = BUCKET_PRESETS[buckets]
68
- fail "#{buckets} is not a valid bucket preset" if @buckets.nil?
69
- else
70
- @buckets = buckets
58
+ def buckets(buckets)
59
+ if buckets.is_a?(Symbol)
60
+ @buckets = BUCKET_PRESETS[buckets]
61
+ fail "#{buckets} is not a valid bucket preset" if @buckets.nil?
62
+ else
63
+ @buckets = buckets
64
+ end
71
65
  end
72
- end
73
66
 
74
- def args(type)
75
- case type
76
- when :gauge
77
- [@doc, @base_labels, @multiprocess_mode]
78
- when :histogram
79
- [@doc, @base_labels, @buckets]
80
- when :counter, :summary
81
- [@doc, @base_labels]
82
- else
83
- fail "Unsupported metric type: #{type}"
67
+ def args(type)
68
+ case type
69
+ when :gauge
70
+ [@doc, @base_labels, @multiprocess_mode]
71
+ when :histogram
72
+ [@doc, @base_labels, @buckets]
73
+ when :counter, :summary
74
+ [@doc, @base_labels]
75
+ else
76
+ fail "Unsupported metric type: #{type}"
77
+ end
84
78
  end
85
- end
86
79
 
87
- def evaluate(&block)
88
- instance_eval(&block) if block_given?
89
- self
80
+ def evaluate(&block)
81
+ instance_eval(&block) if block_given?
82
+ self
83
+ end
90
84
  end
91
85
  end
92
86
  end
@@ -1,3 +1,3 @@
1
1
  module Promenade
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1".freeze
3
3
  end
data/promenade.gemspec CHANGED
@@ -1,5 +1,4 @@
1
-
2
- lib = File.expand_path("../lib", __FILE__)
1
+ lib = File.expand_path("lib", __dir__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require "promenade/version"
5
4
 
@@ -9,22 +8,24 @@ Gem::Specification.new do |spec|
9
8
  spec.authors = ["Ed Robinson"]
10
9
  spec.email = ["edward-robinson@cookpad.com"]
11
10
 
12
- spec.summary = %q{Promenade makes it simple to instrument Ruby apps for prometheus scraping}
11
+ spec.summary = "Promenade makes it simple to instrument Ruby apps for prometheus scraping"
13
12
  spec.homepage = "https://github.com/errm/promenade"
14
13
  spec.license = "MIT"
15
14
 
16
15
  # Specify which files should be added to the gem when it is released.
17
16
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
17
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
19
18
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
19
  end
21
20
 
22
21
  spec.require_paths = ["lib"]
23
22
 
23
+ spec.add_dependency "activesupport"
24
+ spec.add_dependency "prometheus-client-mmap", "~> 0.9.3"
25
+
24
26
  spec.add_development_dependency "bundler", "~> 1.16"
25
27
  spec.add_development_dependency "rake", "~> 10.0"
26
28
  spec.add_development_dependency "rspec", "~> 3.0"
29
+ spec.add_development_dependency "rubocop"
27
30
  spec.add_development_dependency "simplecov"
28
- spec.add_dependency "activesupport"
29
- spec.add_dependency "prometheus-client-mmap", "~> 0.9.3"
30
31
  end
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: promenade
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ed Robinson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-02 00:00:00.000000000 Z
11
+ date: 2018-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: prometheus-client-mmap
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.9.3
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.9.3
13
41
  - !ruby/object:Gem::Dependency
14
42
  name: bundler
15
43
  requirement: !ruby/object:Gem::Requirement
@@ -53,7 +81,7 @@ dependencies:
53
81
  - !ruby/object:Gem::Version
54
82
  version: '3.0'
55
83
  - !ruby/object:Gem::Dependency
56
- name: simplecov
84
+ name: rubocop
57
85
  requirement: !ruby/object:Gem::Requirement
58
86
  requirements:
59
87
  - - ">="
@@ -67,33 +95,19 @@ dependencies:
67
95
  - !ruby/object:Gem::Version
68
96
  version: '0'
69
97
  - !ruby/object:Gem::Dependency
70
- name: activesupport
98
+ name: simplecov
71
99
  requirement: !ruby/object:Gem::Requirement
72
100
  requirements:
73
101
  - - ">="
74
102
  - !ruby/object:Gem::Version
75
103
  version: '0'
76
- type: :runtime
104
+ type: :development
77
105
  prerelease: false
78
106
  version_requirements: !ruby/object:Gem::Requirement
79
107
  requirements:
80
108
  - - ">="
81
109
  - !ruby/object:Gem::Version
82
110
  version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: prometheus-client-mmap
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: 0.9.3
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: 0.9.3
97
111
  description:
98
112
  email:
99
113
  - edward-robinson@cookpad.com
@@ -103,6 +117,7 @@ extra_rdoc_files: []
103
117
  files:
104
118
  - ".gitignore"
105
119
  - ".rspec"
120
+ - ".rubocop.yml"
106
121
  - ".travis.yml"
107
122
  - CODE_OF_CONDUCT.md
108
123
  - Gemfile
@@ -115,6 +130,13 @@ files:
115
130
  - bin/setup
116
131
  - lib/promenade.rb
117
132
  - lib/promenade/helper.rb
133
+ - lib/promenade/kafka.rb
134
+ - lib/promenade/kafka/async_producer_subscriber.rb
135
+ - lib/promenade/kafka/connection_subscriber.rb
136
+ - lib/promenade/kafka/consumer_subscriber.rb
137
+ - lib/promenade/kafka/fetcher_subscriber.rb
138
+ - lib/promenade/kafka/producer_subscriber.rb
139
+ - lib/promenade/kafka/subscriber.rb
118
140
  - lib/promenade/prometheus.rb
119
141
  - lib/promenade/version.rb
120
142
  - promenade.gemspec