deployagram-karafka 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +14 -0
- data/README.md +12 -0
- data/lib/deployagram/karafka.rb +35 -0
- metadata +61 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: a5ef47f2430d24103e8083135c258e5b62a9d063c3a9b93ba9e3be11072a8c9d
|
|
4
|
+
data.tar.gz: 33fa8a7ae83219e888071aabf0e2d3693e8dc00d08424b584e4de39e26623bee
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: f27d95002e4cbdefcf9d2dd2a5e14e84f2124b9b0d254c3cb13b46a97fc5dfcd6bb962f4aee6d72c0ea817998fea76737dfafc3f08355cf356efedb5349c1a76
|
|
7
|
+
data.tar.gz: 26889e1004f35f4e0bf5e1361394113a3b98fc79a15d1c9240b197ccf351d0c016b206f318594e05429a6741212f8b0d44c097f68836c9d8402470f08a2386be
|
data/LICENSE
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
DEPLOYAGRAM PROPRIETARY LICENSE
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Deployagram, Cookiebit and Andy Muir.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted to use this software solely for its intended purpose.
|
|
6
|
+
|
|
7
|
+
RESTRICTIONS:
|
|
8
|
+
- No modification of the software is permitted
|
|
9
|
+
- No reverse engineering, decompilation, or disassembly
|
|
10
|
+
- No redistribution without explicit written permission
|
|
11
|
+
- Source code remains proprietary and confidential
|
|
12
|
+
- Usage is limited to the compiled npm package (the distributed tarball) artifact only
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.
|
data/README.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# deployagram-karafka
|
|
2
|
+
|
|
3
|
+
Records the messages a Karafka consumer handles, and the messages a Karafka producer writes, to the Deployagram Collector.
|
|
4
|
+
|
|
5
|
+
- `record_consumed` subscribes to Karafka's `consumer.consume` event, which fires before the consumer runs.
|
|
6
|
+
- `record_produced` takes the delivery report that `produce_sync` returns once the broker has acknowledged the message.
|
|
7
|
+
|
|
8
|
+
Requires the karafka gem in the application.
|
|
9
|
+
|
|
10
|
+
Depends on: `deployagram-kafka`.
|
|
11
|
+
|
|
12
|
+
Part of the Deployagram Ruby packages. See `../../README.md`.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require "deployagram/kafka"
|
|
2
|
+
|
|
3
|
+
module Deployagram
|
|
4
|
+
# Karafka recording. Karafka publishes "consumer.consume" when it is about to run a consumer's consume method, with
|
|
5
|
+
# the batch's messages available. The recorder subscribes to that event and records each message's coordinates with
|
|
6
|
+
# Deployagram::Kafka.record_consumed before the application handles it, as the Java and Node recorders do. The
|
|
7
|
+
# application needs no instrumentation: subscribe the recorder in the process that runs the consumers.
|
|
8
|
+
#
|
|
9
|
+
# Do not use "consumer.consumed": Karafka publishes it after the block has run, so the record would follow the
|
|
10
|
+
# application's HTTP calls.
|
|
11
|
+
module Karafka
|
|
12
|
+
CONSUME_EVENT = "consumer.consume".freeze
|
|
13
|
+
|
|
14
|
+
module_function
|
|
15
|
+
|
|
16
|
+
# monitor: Karafka's monitor, Karafka.monitor. It is passed in so that this file does not load Karafka itself.
|
|
17
|
+
def record_consumed(logger, consuming_app:, monitor:)
|
|
18
|
+
monitor.subscribe(CONSUME_EVENT) do |event|
|
|
19
|
+
event[:caller].messages.each do |message|
|
|
20
|
+
metadata = message.metadata
|
|
21
|
+
Kafka.record_consumed(logger, consuming_app: consuming_app, topic: metadata.topic,
|
|
22
|
+
partition: metadata.partition, offset: metadata.offset)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Records a message a Karafka producer has written. Karafka's produce_sync returns a delivery report once the broker
|
|
28
|
+
# has acknowledged the message, and the report holds its partition and offset. Call this with that report, and the
|
|
29
|
+
# topic the message was written to.
|
|
30
|
+
def record_produced(logger, producing_app:, topic:, report:)
|
|
31
|
+
Kafka.record_produced(logger, producing_app: producing_app, topic: topic, partition: report.partition,
|
|
32
|
+
offset: report.offset)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: deployagram-karafka
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Deployagram
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: deployagram-kafka
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
-
|
|
17
|
+
- "="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 0.1.0
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
-
|
|
25
|
+
- "="
|
|
26
|
+
- !ruby/object:Gem::Version
|
|
27
|
+
version: 0.1.0
|
|
28
|
+
description: "Subscribes to Karafka's consumer.consume event, which fires before the consumer runs. Requires the karafka gem in the application."
|
|
29
|
+
email:
|
|
30
|
+
- andy@deployagram.com
|
|
31
|
+
executables: []
|
|
32
|
+
extensions: []
|
|
33
|
+
extra_rdoc_files: []
|
|
34
|
+
files:
|
|
35
|
+
- LICENSE
|
|
36
|
+
- README.md
|
|
37
|
+
- lib/deployagram/karafka.rb
|
|
38
|
+
licenses:
|
|
39
|
+
- SEE LICENSE IN LICENSE
|
|
40
|
+
metadata:
|
|
41
|
+
rubygems_mfa_required: "true"
|
|
42
|
+
rdoc_options: []
|
|
43
|
+
require_paths:
|
|
44
|
+
- lib
|
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
46
|
+
requirements:
|
|
47
|
+
-
|
|
48
|
+
- ">="
|
|
49
|
+
- !ruby/object:Gem::Version
|
|
50
|
+
version: "3.2"
|
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
52
|
+
requirements:
|
|
53
|
+
-
|
|
54
|
+
- ">="
|
|
55
|
+
- !ruby/object:Gem::Version
|
|
56
|
+
version: "0"
|
|
57
|
+
requirements: []
|
|
58
|
+
rubygems_version: 4.1.0
|
|
59
|
+
specification_version: 4
|
|
60
|
+
summary: Records the messages a Karafka consumer handles to the Deployagram Collector
|
|
61
|
+
test_files: []
|