Skip to content

add metrics for tracking pg_pool#320

Merged
slowbackspace merged 2 commits intomasterfrom
pg_pool-metrics
Mar 30, 2026
Merged

add metrics for tracking pg_pool#320
slowbackspace merged 2 commits intomasterfrom
pg_pool-metrics

Conversation

@cleverca22
Copy link
Copy Markdown
Contributor

@cleverca22 cleverca22 commented Mar 28, 2026

$ curl -s localhost:3000/metrics | grep pg_pool
# HELP pg_pool_total_count total pg_pool connections
# TYPE pg_pool_total_count gauge
pg_pool_total_count 0
# HELP pg_pool_idle_count idle pg_pool connections
# TYPE pg_pool_idle_count gauge
pg_pool_idle_count 0
# HELP pg_pool_waiting_count waiting pg_pool connections
# TYPE pg_pool_waiting_count gauge
pg_pool_waiting_count 0

this adds 3 new metrics to ryo, to track the state of the pg_pool within it

@cleverca22 cleverca22 force-pushed the pg_pool-metrics branch 30 times, most recently from 74a16f4 to ebe82fb Compare March 29, 2026 06:12
@cleverca22 cleverca22 force-pushed the pg_pool-metrics branch 5 times, most recently from 146eab2 to 1e110cb Compare March 29, 2026 23:07
@hlolli
Copy link
Copy Markdown
Contributor

hlolli commented Mar 30, 2026

@copilot review

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 30, 2026

@copilot review

Here's a summary of the PR changes:

src/app.ts

  • Metrics endpoint renamed from /prometheus/metrics
  • initMetrics() is called inside app.after() to ensure fastify-metrics is fully loaded first
  • node_instance default label added for PM2 cluster mode — fixed (68e8917): it was unconditionally set, so NODE_APP_INSTANCE=undefined would produce a string "undefined" label in non-PM2 environments. Now only set when the env var is actually defined
  • 3 new pg_pool_* gauges read from app.pg.dbSync.pool via the lazy collect() callback, so they're safe to create before fastifyPostgres is registered

src/server.ts

  • ignoreTrailingSlash moved from top-level Fastify options into routerOptions (correct placement for newer Fastify versions)

default.nix / flake.nix

  • New blockfrost-backend-ryo-wrapper derivation that installs pm2-prom-module before starting the app, enabling metric aggregation across PM2 cluster instances
  • default package now points to the wrapper

Copilot AI requested a review from hlolli March 30, 2026 06:25
@hlolli
Copy link
Copy Markdown
Contributor

hlolli commented Mar 30, 2026

it seems the default label thingy was ok change, but I'll need to tell copilot NOT to just commit a change without human approval, sorry about that @cleverca22

@slowbackspace slowbackspace merged commit e3adf79 into master Mar 30, 2026
1 check passed
@cleverca22 cleverca22 deleted the pg_pool-metrics branch March 30, 2026 08:18
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