trellis-pg 0.1.0.pre.beta-aarch64-linux → 0.1.1-aarch64-linux

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: 6966a6e7b852cf951a4599b76e95cca5c937783cb856bf36466b135f1dd4b7f8
4
- data.tar.gz: 9ff1a7ec48a54a20f647a20b996eee9f8f638046489bf58a2f4dcc7f123ddda8
3
+ metadata.gz: 07c2be12b3a8d2c7e5324c7dbae883106be67420efb3a64ba8fb3a365b0a660e
4
+ data.tar.gz: '07490a689fc742d09734443ef2ea4e2789d67d3a6e354677cf6e5faafebca2af'
5
5
  SHA512:
6
- metadata.gz: 6309cad2e8a86315b428ae7dfdfc75fa5c66ea632972b85ce096b50615c1411e5fe2d1c157becd1bca4e32f47627adafb8dbc11ff619ee5804fea86746eae82b
7
- data.tar.gz: 2e090a38bb47cf3c54fbfacc8100f5a9f255320aca827ef7d6f7a476f31bb2462857cee304bbdd435fa14f7d074703759ff56f9ddd6a2bfd6365ceba55288221
6
+ metadata.gz: ffa12c9c92c12ac97cb8ea0dea20fb3f09396ee7f70a9e11ad24e350ea3488eb1aee512c62de8fffbd745d0d6ed4361bcdcf40412cb8995404022247fb3ecfc2
7
+ data.tar.gz: a2b477683e6d523306a1514ef2ba3eee0f0378726266dddd3068c55b3a0af836d061738f621c16042344b1b892262349dc9107cbc1d11261ad190f2766bc0dc5
data/README.md CHANGED
@@ -18,12 +18,9 @@ as `trellis/pg`. The module is still `Trellis`.
18
18
 
19
19
  ```ruby
20
20
  # Gemfile
21
- gem "trellis-pg", "0.1.0.pre.alpha"
21
+ gem "trellis-pg", "~> 0.1.0"
22
22
  ```
23
23
 
24
- A prerelease is installed by naming it: `gem install trellis-pg --pre`, or the
25
- version above in a Gemfile.
26
-
27
24
  `Bundler.require`, which a Rails app's `config/application.rb` runs,
28
25
  requires it by itself. Anywhere else, `require "trellis/pg"`.
29
26
 
@@ -103,6 +100,9 @@ Nothing in the binding uses it.
103
100
  and `self_check_job` returns `nil` for the replaced job or one whose
104
101
  transform was dropped. With no drain worker anywhere in the fleet a job
105
102
  stays `:queued`.
103
+ - `Trellis::Metrics.render_prometheus`: the process-wide metrics registry as
104
+ Prometheus text, for a `/metrics` route the app already serves (the
105
+ binding opens no port; see [Metrics](#metrics)). It needs no handle.
106
106
 
107
107
  ```ruby
108
108
  require "trellis/pg"
@@ -172,6 +172,32 @@ Every handle (each `Trellis::Instance` too) costs this again. The full
172
172
  accounting is in
173
173
  [`docs/embedding.md`](../../docs/embedding.md#what-a-handle-uses).
174
174
 
175
+ ### Metrics
176
+
177
+ The engine's metrics live in one registry per process, holding the series of
178
+ every handle in it; `Trellis::Metrics.render_prometheus` renders them in
179
+ Prometheus's text format. Every series carries a `trellis_instance` label
180
+ (`<database>/<catalog schema>`), so instances in one process stay apart, and
181
+ `trellis_instance_up` is 1 while an instance's handle runs and 0 after it
182
+ shuts down. The metrics themselves are listed in
183
+ [`docs/observability.md`](../../docs/observability.md).
184
+
185
+ The binding opens no port, so serve the text from a route of the app's own:
186
+
187
+ ```ruby
188
+ # config/routes.rb
189
+ get "/metrics", to: proc {
190
+ [200, { "content-type" => "text/plain; version=0.0.4" }, [Trellis::Metrics.render_prometheus]]
191
+ }
192
+ ```
193
+
194
+ Under a forking server each worker process has its own registry, holding
195
+ only its own handles' series, so Prometheus scrapes each worker (or the
196
+ worker handle, `staging: true`, runs in a process of its own that it
197
+ scrapes). A process forked while its parent had a handle running can't
198
+ render the registry, as it can't connect: it raises
199
+ `Trellis::ForkedHandleError` (see [Forking servers](#forking-servers)).
200
+
175
201
  ### Several instances
176
202
 
177
203
  A process can hold several Trellis instances, for different catalog schemas
@@ -524,6 +550,7 @@ source rows; a test database has none, so that is immediate. Runtime state
524
550
  ## Layout
525
551
 
526
552
  - `lib/`: the `Trellis` module and `Trellis::Instance`, its error classes and its `Data` values,
553
+ `Trellis::Metrics`,
527
554
  the Rails integration (`trellis/railtie.rb`, `trellis/migration.rb`),
528
555
  loaded only in an app that has Rails, and the test helpers
529
556
  (`trellis/test_support.rb`), loaded only when required.
Binary file
Binary file
Binary file
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Trellis
4
+ # The engine's metrics, in Prometheus text exposition format: the Rust
5
+ # crate's trellis::Metrics#render_prometheus
6
+ # (docs/decisions/0009-observability-decisions.md).
7
+ #
8
+ # The registry is process-wide: one body holds the series of every Trellis
9
+ # handle in this process, so it needs no handle and works before
10
+ # Trellis.connect and after Trellis.shutdown. Every series carries a
11
+ # trellis_instance="<database>/<catalog schema>" label, so instances in one
12
+ # process stay apart. trellis_instance_up is 1 while an instance has a
13
+ # running handle and 0 after its last one shuts down; the other gauges of a
14
+ # stopped instance disappear after 60 seconds. See docs/observability.md.
15
+ #
16
+ # The binding opens no port. Serve the text from a route the app already
17
+ # has, for example in Rails:
18
+ #
19
+ # # config/routes.rb
20
+ # get "/metrics", to: proc {
21
+ # [200, { "content-type" => "text/plain; version=0.0.4" }, [Trellis::Metrics.render_prometheus]]
22
+ # }
23
+ #
24
+ # In a forking server each worker process has its own registry, holding
25
+ # only its own handles' series, so scrape every worker (or run the worker
26
+ # handle, staging: true, in a process of its own and scrape that).
27
+ #
28
+ # A process forked while its parent had an engine running may have
29
+ # inherited the registry's lock held, so rendering there raises
30
+ # Trellis::ForkedHandleError, as Trellis.connect does.
31
+ module Metrics
32
+ # Renders the registry's current contents: # HELP and # TYPE lines, then
33
+ # each series' samples.
34
+ def self.render_prometheus
35
+ Native.render_prometheus
36
+ end
37
+ end
38
+ end
data/lib/trellis/pg.rb CHANGED
@@ -24,6 +24,7 @@ else
24
24
  end
25
25
 
26
26
  require_relative "instance"
27
+ require_relative "metrics"
27
28
 
28
29
  # Embedded Trellis for Ruby apps: a native extension over the `trellis`
29
30
  # crate's BlockingTrellis, so a Rails app can define and run streaming
@@ -48,6 +49,7 @@ require_relative "instance"
48
49
  # - Operations: request_backfill, detect_capture_disruptions, has_live_drain_workers?,
49
50
  # has_live_staging_worker?, watermark_token, await_converged, self_check,
50
51
  # self_check_job.
52
+ # - Metrics: Trellis::Metrics.render_prometheus, which needs no handle.
51
53
  #
52
54
  # # A deploy's migration step: the defaults run nothing in the background.
53
55
  # Trellis.connect(url: "host=localhost dbname=app")
@@ -3,5 +3,5 @@
3
3
  module Trellis
4
4
  # The trellis-pg gem's version: the Trellis release's, which a
5
5
  # `v<VERSION>` tag releases (docs/releasing.md).
6
- VERSION = "0.1.0-beta"
6
+ VERSION = "0.1.1"
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trellis-pg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre.beta
4
+ version: 0.1.1
5
5
  platform: aarch64-linux
6
6
  authors:
7
7
  - Salesforce
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-10-29 00:00:00.000000000 Z
11
+ date: 2026-11-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  A native extension over the trellis crate's BlockingTrellis, so a Rails
@@ -25,6 +25,7 @@ files:
25
25
  - lib/trellis/4.0/trellis_ruby.so
26
26
  - lib/trellis/error.rb
27
27
  - lib/trellis/instance.rb
28
+ - lib/trellis/metrics.rb
28
29
  - lib/trellis/migration.rb
29
30
  - lib/trellis/pg.rb
30
31
  - lib/trellis/railtie.rb