promenade 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/promenade/karafka/consumer_subscriber.rb +46 -0
- data/lib/promenade/karafka/error_subscriber.rb +27 -0
- data/lib/promenade/karafka/statistics_subscriber.rb +80 -0
- data/lib/promenade/karafka/subscriber.rb +8 -0
- data/lib/promenade/karafka.rb +3 -0
- data/lib/promenade/version.rb +1 -1
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc0749131d57843e9243eb47058cc0615c73865b92b753772308ceb13cd6b096
|
4
|
+
data.tar.gz: 66c5a9376ea0cd02dbd64bd63e67d3178f440a30701646912ef459586e14a1e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5569ffe88cbaf2a0a738b605c15673a6866e51c345fc53a8000f01004dd77b23a8175af32f1242ed2492aa444c6a71e20d760fb1d377b2c02ead531470108f47
|
7
|
+
data.tar.gz: b2fe6be44e09a45f9e6cf051971b27140d9af03e436265815ccb0e527d85dfcc890dc271654e3b404ff9cfce8c8a633ff4efe1c17797781ef6751732bb7d92f3
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,46 @@
|
|
1
|
+
require "promenade/karafka/subscriber"
|
2
|
+
|
3
|
+
module Promenade
|
4
|
+
module Karafka
|
5
|
+
class ConsumerSubscriber < Subscriber
|
6
|
+
attach_to "consumer.karafka"
|
7
|
+
|
8
|
+
Promenade.histogram :karafka_consumer_batch_processing_duration_seconds do
|
9
|
+
doc "Consumer message processing latency in seconds"
|
10
|
+
buckets :network
|
11
|
+
end
|
12
|
+
|
13
|
+
Promenade.counter :karafka_consumer_messages_processed do
|
14
|
+
doc "Messages processed by this consumer"
|
15
|
+
end
|
16
|
+
|
17
|
+
def consumed(event)
|
18
|
+
consumer = event.payload[:caller]
|
19
|
+
messages = consumer.messages
|
20
|
+
batch_processing_duration = convert_milliseconds_to_seconds(event.payload[:time])
|
21
|
+
|
22
|
+
labels = get_labels(consumer)
|
23
|
+
|
24
|
+
Promenade.metric(:karafka_consumer_messages_processed).increment(labels, messages.size)
|
25
|
+
Promenade.metric(:karafka_consumer_batch_processing_duration_seconds).observe(labels, batch_processing_duration)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def get_labels(consumer)
|
31
|
+
metadata = consumer.messages.metadata
|
32
|
+
|
33
|
+
{
|
34
|
+
client: consumer.topic.kafka[:"client.id"],
|
35
|
+
group: consumer.topic.consumer_group.id,
|
36
|
+
topic: metadata.topic,
|
37
|
+
partition: metadata.partition,
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
def convert_milliseconds_to_seconds(time_in_milliseconds)
|
42
|
+
time_in_milliseconds / 1000.to_f
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "promenade/karafka/subscriber"
|
2
|
+
|
3
|
+
module Promenade
|
4
|
+
module Karafka
|
5
|
+
class ErrorSubscriber < Subscriber
|
6
|
+
attach_to "error.karafka"
|
7
|
+
|
8
|
+
Promenade.counter :karafka_errors do
|
9
|
+
doc "Count of Kafka connection errors"
|
10
|
+
end
|
11
|
+
|
12
|
+
def occurred(event)
|
13
|
+
labels = get_labels(event)
|
14
|
+
|
15
|
+
Promenade.metric(:karafka_errors).increment(labels)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def get_labels(event)
|
21
|
+
{
|
22
|
+
error_type: event.payload[:type],
|
23
|
+
}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require "promenade/karafka/subscriber"
|
2
|
+
require "active_support/core_ext/hash"
|
3
|
+
|
4
|
+
module Promenade
|
5
|
+
module Karafka
|
6
|
+
class StatisticsSubscriber < Subscriber
|
7
|
+
attach_to "statistics.karafka"
|
8
|
+
|
9
|
+
Promenade.histogram :karafka_connection_latency_seconds do
|
10
|
+
doc "Request latency (rtt) in seconds"
|
11
|
+
buckets :network
|
12
|
+
end
|
13
|
+
|
14
|
+
Promenade.counter :karafka_connection_calls do
|
15
|
+
doc "Count of calls made to Kafka broker"
|
16
|
+
end
|
17
|
+
|
18
|
+
Promenade.gauge :karafka_consumer_offset_lag do
|
19
|
+
doc "Lag between message create and consume time"
|
20
|
+
end
|
21
|
+
|
22
|
+
def emitted(event)
|
23
|
+
group = event.payload[:consumer_group_id]
|
24
|
+
statistics = event.payload[:statistics].with_indifferent_access
|
25
|
+
client_id = statistics[:client_id]
|
26
|
+
|
27
|
+
report_topic_metrics(statistics[:topics], group, client_id)
|
28
|
+
report_connection_metrics(statistics[:brokers], client_id)
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def report_topic_metrics(topics, group, client_id)
|
34
|
+
topics.map do |topic_name, topic_values|
|
35
|
+
labels = {
|
36
|
+
client: client_id,
|
37
|
+
topic: topic_name,
|
38
|
+
group: group,
|
39
|
+
}
|
40
|
+
report_partition_metrics(topic_values, labels)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def report_partition_metrics(topic_values, labels)
|
45
|
+
topic_values[:partitions].map do |partition_name, partition_values|
|
46
|
+
next if partition_name == "-1"
|
47
|
+
next if partition_values[:consumer_lag_stored] == -1
|
48
|
+
|
49
|
+
labels = labels.merge(
|
50
|
+
partition: partition_name,
|
51
|
+
)
|
52
|
+
|
53
|
+
offset_lag = partition_values[:consumer_lag_stored]
|
54
|
+
|
55
|
+
Promenade.metric(:karafka_consumer_offset_lag).set(labels, offset_lag)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def report_connection_metrics(brokers, client_id)
|
60
|
+
labels = {
|
61
|
+
client: client_id,
|
62
|
+
}
|
63
|
+
|
64
|
+
brokers.map do |broker_name, broker_values|
|
65
|
+
next if broker_values[:nodeid] == -1
|
66
|
+
|
67
|
+
rtt = convert_microseconds_to_seconds(broker_values[:rtt][:avg])
|
68
|
+
connection_calls = broker_values[:connects]
|
69
|
+
|
70
|
+
Promenade.metric(:karafka_connection_calls).increment(labels.merge(broker: broker_name), connection_calls)
|
71
|
+
Promenade.metric(:karafka_connection_latency_seconds).observe(labels.merge(broker: broker_name), rtt)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def convert_microseconds_to_seconds(time_in_microseconds)
|
76
|
+
time_in_microseconds / 1_000_000.to_f
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
data/lib/promenade/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: promenade
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ed Robinson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-03-
|
11
|
+
date: 2023-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -288,6 +288,11 @@ files:
|
|
288
288
|
- lib/promenade/kafka/fetcher_subscriber.rb
|
289
289
|
- lib/promenade/kafka/producer_subscriber.rb
|
290
290
|
- lib/promenade/kafka/subscriber.rb
|
291
|
+
- lib/promenade/karafka.rb
|
292
|
+
- lib/promenade/karafka/consumer_subscriber.rb
|
293
|
+
- lib/promenade/karafka/error_subscriber.rb
|
294
|
+
- lib/promenade/karafka/statistics_subscriber.rb
|
295
|
+
- lib/promenade/karafka/subscriber.rb
|
291
296
|
- lib/promenade/prometheus.rb
|
292
297
|
- lib/promenade/railtie.rb
|
293
298
|
- lib/promenade/setup.rb
|
@@ -313,7 +318,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
313
318
|
- !ruby/object:Gem::Version
|
314
319
|
version: '0'
|
315
320
|
requirements: []
|
316
|
-
rubygems_version: 3.
|
321
|
+
rubygems_version: 3.3.7
|
317
322
|
signing_key:
|
318
323
|
specification_version: 4
|
319
324
|
summary: Promenade makes it simple to instrument Ruby apps for prometheus scraping
|