deployagram-phobos 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 +8 -0
- data/lib/deployagram/phobos.rb +40 -0
- metadata +61 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: d035aa49bdfd7a6620f42fcfe3c30bc7dcf173c8dc1b5916ea0cbdd515f9abb1
|
|
4
|
+
data.tar.gz: 02efd7d21390c1f79a4c67273bc8919d328bff1f85a73b81cd64d05cf06000ea
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 0b6ace37dda671ec60dd7db65365fa6f215198713b34fcabfa7151c3d0eefd272929e181f64837e41bf01f11a0af7522507af84aed919b4436b0b5802f4083be
|
|
7
|
+
data.tar.gz: 1846d2c573e3322687a4c58feaf838aa4971f1589edc14ce2c4307d9f064eacbede8a1890a3dc75b96856e88dc9993afd6c0460ddaa913278b14a20f147ff170
|
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,8 @@
|
|
|
1
|
+
# deployagram-phobos
|
|
2
|
+
|
|
3
|
+
Records the Kafka records a Phobos handler reads, to the Deployagram Collector. The recorder is prepended to the handler, and
|
|
4
|
+
reports each record in `around_consume`, before the handler runs. Requires the `phobos` gem in the application.
|
|
5
|
+
|
|
6
|
+
Depends on: `deployagram-kafka`.
|
|
7
|
+
|
|
8
|
+
Part of the Deployagram Ruby packages. See `../../README.md`.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
require "active_support"
|
|
2
|
+
require "active_support/notifications"
|
|
3
|
+
require "deployagram/kafka"
|
|
4
|
+
|
|
5
|
+
module Deployagram
|
|
6
|
+
# Records the Kafka records a Phobos handler reads. Phobos calls the handler's around_consume before consume, with the
|
|
7
|
+
# record's topic, partition and offset in the metadata. Prepend the module this returns to the handler class: it
|
|
8
|
+
# reports the record, then calls around_consume, so the Collector shows the read before the handler's HTTP calls.
|
|
9
|
+
#
|
|
10
|
+
# DontForget::EmailHandler.prepend(Deployagram::Phobos.recorder(logger, consuming_app: "DontForget"))
|
|
11
|
+
module Phobos
|
|
12
|
+
# ruby-kafka's instrumenter appends its namespace, so the event name is ack_message.producer.kafka.
|
|
13
|
+
PRODUCER_ACKNOWLEDGED = "ack_message.producer.kafka".freeze
|
|
14
|
+
|
|
15
|
+
module_function
|
|
16
|
+
|
|
17
|
+
def recorder(logger, consuming_app:)
|
|
18
|
+
Module.new do
|
|
19
|
+
define_method(:around_consume) do |payload, metadata, &block|
|
|
20
|
+
Deployagram::Kafka.record_consumed(logger, consuming_app: consuming_app, topic: metadata.fetch(:topic),
|
|
21
|
+
partition: metadata.fetch(:partition), offset: metadata.fetch(:offset))
|
|
22
|
+
super(payload, metadata, &block)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Records each record the process's ruby-kafka producers write. ruby-kafka reports every acknowledged record as an
|
|
28
|
+
# ack_message.producer notification with its topic, partition and offset, and Phobos loads ActiveSupport, so the
|
|
29
|
+
# notification reaches the subscriber. Phobos's publish returns only after the broker acknowledges, so each record
|
|
30
|
+
# is recorded before the publish returns. Call this once, before publishing. Returns the subscriber, which
|
|
31
|
+
# ActiveSupport::Notifications.unsubscribe takes to stop recording.
|
|
32
|
+
def producer_recorder(logger, producing_app:)
|
|
33
|
+
ActiveSupport::Notifications.subscribe(PRODUCER_ACKNOWLEDGED) do |*args|
|
|
34
|
+
record = ActiveSupport::Notifications::Event.new(*args).payload
|
|
35
|
+
Deployagram::Kafka.record_produced(logger, producing_app: producing_app, topic: record.fetch(:topic),
|
|
36
|
+
partition: record.fetch(:partition), offset: record.fetch(:offset))
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: deployagram-phobos
|
|
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: "A Phobos handler recorder: it reports each consumed record in around_consume, before the handler runs. Requires the phobos 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/phobos.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 Kafka records a Phobos handler reads, to the Deployagram Collector"
|
|
61
|
+
test_files: []
|