deployangel 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f2cfd7db0190a370bcb7e464ee8f43edf3674b46035db0c18836826f489bd760
4
- data.tar.gz: 061c91c247bd1633fa5ab5b36c04b89f3e5fb74d8217c5cca66401d101c5332d
3
+ metadata.gz: bd9c6a1966ad36b07d9544c19cfc0b431afd75794ec53f8710792b078e6370ba
4
+ data.tar.gz: 7048de09969cb804f374efbe9e3117402b9e7d048faceb45ad8390707d1e01ac
5
5
  SHA512:
6
- metadata.gz: c07d0699f4927f133484e6521894da8abb59e1f26b5271e3d21ca8b820fd39093a66036887c17a65079a326d487247c2fbd95dc7d7fb92d98185487814fb027f
7
- data.tar.gz: 47c69848596e777ff7555a6c9ee9f5b12e38c4186fdb70bf48d9c8b25ff143c0c8a6abb2070a8e9b696fea0583697c148d91260f6426e73a79defe725bf2ca50
6
+ metadata.gz: 0d11c1b1a206d317f433af474f908fabdc0aae002d36b5977577c5691c9756a0717b2377a4e09815b299ea9c9e096402f74742ca7bb204ae2f2be97bd277b581
7
+ data.tar.gz: 3fa2290369ffdb891d9eb575e4ba90187b3576146a46310e31319352b4ae408b0aae7e1659e5bb45adaf400eea6ca6dab02c032f143d527daf0212a6c5505f17
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.2 (2026-10-02)
4
+
5
+ - Unsent minutes wait in the buffer as gzipped JSON rather than Ruby objects.
6
+ With every list at its cap, 10 minutes queued while DeployAngel was
7
+ unreachable took about 20 MB; they now take well under 1 MB.
8
+ - `rake bench` measures the agent's overhead: time and allocations per
9
+ request, memory with every list at its cap, and the file digest pass.
10
+
3
11
  ## 0.1.1 (2026-10-02)
4
12
 
5
13
  - Declared Solid Queue schedules carry the time zone Solid Queue reads them
data/README.md CHANGED
@@ -78,11 +78,18 @@ user data.
78
78
  in-memory counters.
79
79
  - Payloads are sent from a background thread, once a minute, with short
80
80
  timeouts.
81
- - When DeployAngel is unreachable, the buffer is bounded (10 payloads) and the
82
- oldest are dropped. Your app is never blocked or failed.
81
+ - When DeployAngel is unreachable, the buffer is bounded (10 payloads, kept as
82
+ gzipped JSON) and the oldest are dropped. Your app is never blocked or failed.
83
83
  - Safe across forks (Puma cluster mode and similar), and the minute in progress
84
84
  is flushed at shutdown.
85
85
 
86
+ `bundle exec rake bench` measures this: the time and allocations each request
87
+ adds, memory with every list at its cap, and the one-time file digest pass
88
+ (`APP_ROOT=path/to/app` to digest your own app). On an Apple M-series laptop
89
+ with Ruby 3.4, recording a request adds about 1.6 µs and 6 objects, and with
90
+ every route, job, checkpoint, and exception list at its cap the agent holds
91
+ about 3 MB, including 10 unsent minutes.
92
+
86
93
  ## Configuration
87
94
 
88
95
  Environment variables are enough for most apps. To override in code:
@@ -97,13 +97,14 @@ module DeployAngel
97
97
  DeployAngel.capabilities
98
98
  end
99
99
 
100
- # Drains completed minutes into the buffer and sends what it can.
100
+ # Drains completed minutes into the buffer, encoded so unsent minutes stay
101
+ # small while DeployAngel is unreachable, and sends what it can.
101
102
  def flush(include_current: false)
102
103
  return 0 unless @active
103
104
 
104
105
  @aggregator.drain(include_current: include_current, max_periods: config.max_queued_payloads).each do |period|
105
- @buffer.push(Protocol.telemetry(period, instance: @instance, release: @release, runtime: @runtime,
106
- capabilities: capabilities))
106
+ @buffer.push(Transport.encode(Protocol.telemetry(period, instance: @instance, release: @release,
107
+ runtime: @runtime, capabilities: capabilities)))
107
108
  end
108
109
  send_buffered
109
110
  rescue StandardError => e
@@ -16,10 +16,28 @@ module DeployAngel
16
16
  end
17
17
  end
18
18
 
19
+ # A payload already encoded as gzipped JSON. Queued telemetry is kept
20
+ # this way: a full minute is megabytes as Ruby objects but kilobytes
21
+ # compressed.
22
+ Encoded = Struct.new(:bytes)
23
+
24
+ def self.encode(body)
25
+ Encoded.new(gzip(JSON.generate(body)))
26
+ end
27
+
28
+ def self.gzip(string)
29
+ io = StringIO.new
30
+ writer = Zlib::GzipWriter.new(io)
31
+ writer.write(string)
32
+ writer.close
33
+ io.string
34
+ end
35
+
19
36
  def initialize(config)
20
37
  @config = config
21
38
  end
22
39
 
40
+ # body is a Hash, or an Encoded payload sent as is.
23
41
  # :ok (2xx), :retry (network error or 5xx), or :drop (any other status,
24
42
  # including 429 rate limiting, which the agent honors by pausing).
25
43
  def post(path, body)
@@ -29,7 +47,7 @@ module DeployAngel
29
47
  request["Content-Type"] = "application/json"
30
48
  request["Content-Encoding"] = "gzip"
31
49
  request["User-Agent"] = "deployangel-ruby/#{DeployAngel::VERSION} ruby/#{RUBY_VERSION}"
32
- request.body = gzip(JSON.generate(body))
50
+ request.body = (body.is_a?(Encoded) ? body : self.class.encode(body)).bytes
33
51
 
34
52
  response = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https",
35
53
  open_timeout: @config.open_timeout, read_timeout: @config.read_timeout,
@@ -54,13 +72,5 @@ module DeployAngel
54
72
  rescue JSON::ParserError
55
73
  {}
56
74
  end
57
-
58
- def gzip(string)
59
- io = StringIO.new
60
- writer = Zlib::GzipWriter.new(io)
61
- writer.write(string)
62
- writer.close
63
- io.string
64
- end
65
75
  end
66
76
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DeployAngel
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deployangel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jordan Owens