trellis-pg 0.1.0.pre.beta-x86_64-linux → 0.1.0.pre.gamma-x86_64-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 +4 -4
- data/README.md +30 -0
- data/lib/trellis/3.3/trellis_ruby.so +0 -0
- data/lib/trellis/3.4/trellis_ruby.so +0 -0
- data/lib/trellis/4.0/trellis_ruby.so +0 -0
- data/lib/trellis/metrics.rb +38 -0
- data/lib/trellis/pg.rb +2 -0
- data/lib/trellis/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e18f0e6ed130544487637158d07dde5df97b1ca71be833a2c83de5707bc57caf
|
|
4
|
+
data.tar.gz: 71362e6e792f82b2981c617a905e2902728845144cdeda6fe61db0e6456cdfec
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5caa307be2a264f46ea22831af13a4f8b13ce7884fb85e5f212d021842f699087a30ce3885d8d28810df710961efbfb2203ae86493c4da5b422ed54e487b1a85
|
|
7
|
+
data.tar.gz: 3af1b8ff7efea4b7d51506a49a99d312344c8469006704edb501ecb02838f28bf5ee8dcba45d12c768436f8658f00dfd10e58039e7c28c70bc2b87f6878c8030
|
data/README.md
CHANGED
|
@@ -103,6 +103,9 @@ Nothing in the binding uses it.
|
|
|
103
103
|
and `self_check_job` returns `nil` for the replaced job or one whose
|
|
104
104
|
transform was dropped. With no drain worker anywhere in the fleet a job
|
|
105
105
|
stays `:queued`.
|
|
106
|
+
- `Trellis::Metrics.render_prometheus`: the process-wide metrics registry as
|
|
107
|
+
Prometheus text, for a `/metrics` route the app already serves (the
|
|
108
|
+
binding opens no port; see [Metrics](#metrics)). It needs no handle.
|
|
106
109
|
|
|
107
110
|
```ruby
|
|
108
111
|
require "trellis/pg"
|
|
@@ -172,6 +175,32 @@ Every handle (each `Trellis::Instance` too) costs this again. The full
|
|
|
172
175
|
accounting is in
|
|
173
176
|
[`docs/embedding.md`](../../docs/embedding.md#what-a-handle-uses).
|
|
174
177
|
|
|
178
|
+
### Metrics
|
|
179
|
+
|
|
180
|
+
The engine's metrics live in one registry per process, holding the series of
|
|
181
|
+
every handle in it; `Trellis::Metrics.render_prometheus` renders them in
|
|
182
|
+
Prometheus's text format. Every series carries a `trellis_instance` label
|
|
183
|
+
(`<database>/<catalog schema>`), so instances in one process stay apart, and
|
|
184
|
+
`trellis_instance_up` is 1 while an instance's handle runs and 0 after it
|
|
185
|
+
shuts down. The metrics themselves are listed in
|
|
186
|
+
[`docs/observability.md`](../../docs/observability.md).
|
|
187
|
+
|
|
188
|
+
The binding opens no port, so serve the text from a route of the app's own:
|
|
189
|
+
|
|
190
|
+
```ruby
|
|
191
|
+
# config/routes.rb
|
|
192
|
+
get "/metrics", to: proc {
|
|
193
|
+
[200, { "content-type" => "text/plain; version=0.0.4" }, [Trellis::Metrics.render_prometheus]]
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Under a forking server each worker process has its own registry, holding
|
|
198
|
+
only its own handles' series, so Prometheus scrapes each worker (or the
|
|
199
|
+
worker handle, `staging: true`, runs in a process of its own that it
|
|
200
|
+
scrapes). A process forked while its parent had a handle running can't
|
|
201
|
+
render the registry, as it can't connect: it raises
|
|
202
|
+
`Trellis::ForkedHandleError` (see [Forking servers](#forking-servers)).
|
|
203
|
+
|
|
175
204
|
### Several instances
|
|
176
205
|
|
|
177
206
|
A process can hold several Trellis instances, for different catalog schemas
|
|
@@ -524,6 +553,7 @@ source rows; a test database has none, so that is immediate. Runtime state
|
|
|
524
553
|
## Layout
|
|
525
554
|
|
|
526
555
|
- `lib/`: the `Trellis` module and `Trellis::Instance`, its error classes and its `Data` values,
|
|
556
|
+
`Trellis::Metrics`,
|
|
527
557
|
the Rails integration (`trellis/railtie.rb`, `trellis/migration.rb`),
|
|
528
558
|
loaded only in an app that has Rails, and the test helpers
|
|
529
559
|
(`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")
|
data/lib/trellis/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: trellis-pg
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.0.pre.
|
|
4
|
+
version: 0.1.0.pre.gamma
|
|
5
5
|
platform: x86_64-linux
|
|
6
6
|
authors:
|
|
7
7
|
- Salesforce
|
|
@@ -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
|