Skip to content

chore: Modernize signals pgbouncer-mixin - #1663

Open
postnati wants to merge 4 commits into
grafana:masterfrom
postnati:chore/pgbouncer-mixin-modernization
Open

chore: Modernize signals pgbouncer-mixin#1663
postnati wants to merge 4 commits into
grafana:masterfrom
postnati:chore/pgbouncer-mixin-modernization

Conversation

@postnati

Copy link
Copy Markdown
Contributor

This PR modernizes pgbouncer-mixin to use the signals architecture pattern.

@cla-assistant

cla-assistant Bot commented Jun 29, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@postnati
postnati force-pushed the chore/pgbouncer-mixin-modernization branch from fbaf322 to 8775594 Compare July 16, 2026 13:03
@postnati
postnati marked this pull request as ready for review July 16, 2026 13:03
@postnati
postnati requested a review from a team as a code owner July 16, 2026 13:03
@Dasomeone

Copy link
Copy Markdown
Member

Hi @postnati just a quick note that all commits must be signed with a valid GPG key in order to unblock merging, will be needed across all your PRs

@schmikei schmikei left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from rebasing your commits to be signed I think that the changes here look relatively straightforward!

@Dasomeone Dasomeone left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs the same overhaul as mentioned in comments around panels here #1668 (review)

@postnati
postnati force-pushed the chore/pgbouncer-mixin-modernization branch 2 times, most recently from 240f1da to b5b3aa3 Compare July 24, 2026 14:50
@postnati

Copy link
Copy Markdown
Contributor Author

Updated and ready for review.

@postnati

postnati commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Converted the signals from raw to typed and used appropriate aggFunction, rangeFunction, and exprWrappers.

postnati and others added 4 commits August 6, 2026 12:16
Addresses review feedback (Case 2, the asTarget() feedback). Case 1 did not
apply: the signal files already spell out every signal object, with no local
signal-builder helper to expand.

Single-signal stat and timeSeries panels now use signals.<group>.<name>.asStat()
/ .asTimeSeries() + commonlib.panels.generic.<flavor>.stylize() + the unchanged
panel-specific mixins, instead of commonlib...base.new(targets=[sig.asTarget()]).
Panel title/unit/description are sourced from the signal spec; panel-level
withUnit() and inline description/targets are removed. Two signals shared between
a stat (no unit) and a timeSeries (with unit) keep their spec matched to the stat
and set title/unit at the timeSeries call site via withName()/withUnit().

Panels that must stay target-based (documented in panels.libsonnet): the three
multi-signal timeSeries (Network traffic, Server connections, Top databases by
network traffic) and the alertList panel — common-lib provides no signal
constructor for multi-series traffic panels or alert lists.

Verified with a Python per-panel comparator against the grafana/master
pre-modernization baseline: every panel of every dashboard matches modulo the
excluded editor/id/datasource fields. logs.json is byte-identical. Accepted
output deltas on converted panels:
  1. one per-query fieldConfig override (matcher byFrameRefID, single unit
     property == signal unit) plus fieldConfig.defaults.unit (== '' / absent on
     the unit-less stat panels);
  2. converted timeSeries descriptions drop the trailing newline that the legacy
     ||| block descriptions carried (cosmetic; markdown renders identically).
No expr, legend, title, or interval deltas.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…signal specs

Addresses the "everything is type: raw" review feedback. Raw signals drop from
7/22 (32%) to 3/24 (12%).

signals/cluster.libsonnet: four of the five "top database" signals were raw with
the whole legacy expression baked in. They are now typed — top_database_active_
connection as gauge, and top_database_query_processed / _network_received /
_network_sent as counter (rate is the framework default) — with the topk
by-clause and $top_database_count supplied through exprWrappers. The wrapper is
written out inline on each signal rather than hoisted into a local.

top_database_query_duration stays raw, as do stats_query_avg_duration and
stats_transaction_avg_duration: all three are a ratio of two range vectors
(1000 * increase(a) / clamp_min(increase(b), 1)), which no typed signal can
express. Only the topk wrapper is factored out of the cluster one.

Query shape moved out of panels.libsonnet and into the signal specs. The stat
panels need a bare sum() with no by-clause, which the aggregation template
cannot emit, so those signals carry exprWrappers: [['sum(', ')']] and an empty
legendCustomTemplate. Where one metric is shown both as a summed stat and as
per-database series, each view is now its own signal (the _total suffix marks
the summed one) instead of one signal mutated at two call sites. panels.libsonnet
now has no call-site signal mutation at all: every single-signal panel is
signals.<group>.<name>.asStat()/.asTimeSeries() + stylize().

Intentional semantic change: the three hand-written raw signals that use
increase() now carry the same window the framework emits for a typed increase
counter — [$__interval:] offset -$__interval, in both the numerator and the
denominator of each ratio. The negative offset shifts the window forward so the
newest bucket is complete rather than partial, so "Queries average duration",
"SQL average transaction duration" and "Top databases by average query duration"
stop under-reporting at the right-hand edge. Both halves of each ratio shift by
the same amount, so the ratio stays coherent.

Verified with a Python leaf-path comparator against both the branch HEAD baseline
and the grafana/master pre-modernization baseline. Against master, every panel
matches on title, gridPos, panel type, legend and target count, with these
categories of delta and nothing else:
  21  expr: trailing-comma / whitespace only
  10  description: trailing newline dropped (cosmetic, markdown identical)
   6  stat panel unit: None <-> '' (renders identically)
   3  expr: + offset -$__interval (the intentional change above)
The offset exprs were re-compared with the offset tokens stripped back out and
then match master exactly, confirming it is the only semantic addition.

prometheus_rules_out/ is byte-unchanged; the alerts are threshold comparisons on
instant gauges with no range functions and reference no signals. make fmt, make
lint and make -B all are clean and the build is reproducible.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@postnati
postnati force-pushed the chore/pgbouncer-mixin-modernization branch from a36a3fc to 76aeead Compare August 6, 2026 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants