Skip to content

feat(price-pusher): emit namespace label on all Prometheus metrics#3720

Open
0xghost42 wants to merge 1 commit into
pyth-network:mainfrom
0xghost42:feat/3692-metrics-namespace-label
Open

feat(price-pusher): emit namespace label on all Prometheus metrics#3720
0xghost42 wants to merge 1 commit into
pyth-network:mainfrom
0xghost42:feat/3692-metrics-namespace-label

Conversation

@0xghost42
Copy link
Copy Markdown

@0xghost42 0xghost42 commented May 19, 2026

Summary

Make the sample Grafana dashboard's namespace=\$chain filters actually match emitted series, which they don't today.

Background

apps/price_pusher/grafana-dashboard.sample.json queries every panel with namespace="\$chain", e.g.

pyth_price_feeds_total{namespace="\$chain"}
pyth_price_last_published_time{namespace="\$chain"}
pyth_price_update_attempts_total{namespace="\$chain", status="success"}

But apps/price_pusher/src/metrics.ts only set app="price_pusher" as the default registry label, and prometheus.sample.yml doesn't add namespace via relabeling either. The result: every panel in the sample dashboard came up empty on a fresh deployment.

Devin flagged this during the #3692 review and I acknowledged it there as pre-existing dashboard behavior worth fixing in a separate PR. This is that PR.

Wiring

  • new CLI option --metrics-namespace <name> in src/options.ts, defaulted per chain command (evm, sui, aptos, solana) so single-chain deployments work without any configuration
  • PricePusherMetrics constructor now takes a namespace: string parameter and sets it via registry.setDefaultLabels, so every existing metric series gains a namespace label without per-metric labelNames plumbing
  • each chain command (evm/sui/aptos/solana/command.ts) reads the new arg and passes through to the constructor

Operators running multiple deployments of the same chain (e.g. several EVM networks against one Grafana instance) can now set --metrics-namespace bsc-mainnet / --metrics-namespace polygon-mainnet to disambiguate. Single-deployment setups keep working unchanged — the dashboard's \$chain template var will just match the chain command name out of the box.

Bumps @pythnetwork/price-pusher to 10.5.0.

Coordination heads-up

#3689 and #3703 (both open) also bump to 10.5.0. Whichever of the three lands second/third will need a trivial rebase to 10.6.0 / 10.7.0.

Test plan

  • CLI --help exposes new --metrics-namespace option on each chain
  • Default (no --metrics-namespace): curl :9090/metrics shows pyth_*{...namespace="evm",...} (or sui/aptos/solana)
  • Override: --metrics-namespace bsc-mainnet yields namespace="bsc-mainnet" on every emitted series
  • Sample Grafana dashboard's \$chain=\$namespace panels populate end-to-end against a real pusher
  • Maintainer signoff on the per-chain default values (evm/sui/aptos/solana)

Refs #3692.


Open in Devin Review

The sample Grafana dashboard (`grafana-dashboard.sample.json`) filters
every Prometheus query by `namespace=$chain`:

  pyth_price_feeds_total{namespace="$chain"}
  pyth_price_last_published_time{namespace="$chain"}
  pyth_price_update_attempts_total{namespace="$chain", ...}
  ...

But `src/metrics.ts` only set `app="price_pusher"` as the default label
and never emitted a `namespace` label on any counter/gauge, and
`prometheus.sample.yml` did not add one via relabeling. With the
dashboard out of the box that filter matched zero series, so every
panel for a fresh deployment came up empty — flagged by Devin during
review of pyth-network#3692 and acknowledged there as pre-existing dashboard
behavior worth fixing in a separate PR. This is that PR.

Wiring:

  - new CLI option `--metrics-namespace <name>` in `src/options.ts`,
    defaulted per chain command (`evm`, `sui`, `aptos`, `solana`) so
    that single-chain deployments work without configuration
  - `PricePusherMetrics` constructor now takes a `namespace: string`
    parameter and sets it via `registry.setDefaultLabels`, so every
    existing metric series gains a `namespace` label without per-metric
    `labelNames` plumbing
  - each chain command (`evm/sui/aptos/solana/command.ts`) reads the
    new arg and passes through to the constructor

Operators running multiple deployments of the same chain (e.g. several
EVM networks against one Grafana instance) can now set
`--metrics-namespace bsc-mainnet` / `--metrics-namespace polygon-mainnet`
to disambiguate. Single-deployment setups keep working unchanged.

Bumps `@pythnetwork/price-pusher` to `10.5.0` (additive, no breaking
changes — old CLIs still work). Note: pyth-network#3689 and pyth-network#3703 also bump to
`10.5.0`, so whichever of the three lands second/third will need a
trivial rebase to `10.6.0` / `10.7.0`.

Refs pyth-network#3692.
@0xghost42 0xghost42 requested a review from a team as a code owner May 19, 2026 06:36
@vercel
Copy link
Copy Markdown

vercel Bot commented May 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

7 Skipped Deployments
Project Deployment Actions Updated (UTC)
api-reference Skipped Skipped May 19, 2026 6:36am
component-library Skipped Skipped May 19, 2026 6:36am
developer-hub Skipped Skipped May 19, 2026 6:36am
entropy-explorer Skipped Skipped May 19, 2026 6:36am
insights Skipped Skipped May 19, 2026 6:36am
proposals Skipped Skipped May 19, 2026 6:36am
staking Skipped Skipped May 19, 2026 6:36am

Request Review

@vercel vercel Bot temporarily deployed to Preview – proposals May 19, 2026 06:36 Inactive
@vercel vercel Bot temporarily deployed to Preview – entropy-explorer May 19, 2026 06:36 Inactive
@vercel vercel Bot temporarily deployed to Preview – developer-hub May 19, 2026 06:36 Inactive
@vercel vercel Bot temporarily deployed to Preview – insights May 19, 2026 06:36 Inactive
@vercel vercel Bot temporarily deployed to Preview – api-reference May 19, 2026 06:36 Inactive
@vercel vercel Bot temporarily deployed to Preview – staking May 19, 2026 06:36 Inactive
@vercel vercel Bot temporarily deployed to Preview – component-library May 19, 2026 06:36 Inactive
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

View 2 additional findings in Devin Review.

Open in Devin Review

// Register the default metrics (memory, CPU, etc.). `namespace` is set as
// a default label so the sample Grafana dashboard's `namespace=$chain`
// filter actually matches emitted series.
this.registry.setDefaultLabels({ app: "price_pusher", namespace });
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.

🚩 Prometheus namespace label may collide with Kubernetes service-discovery labels

The new default label namespace set at apps/price_pusher/src/metrics.ts:34 is a very common label auto-applied by Kubernetes Prometheus service discovery (typically representing the k8s namespace of the pod). If the price pusher runs inside Kubernetes and Prometheus is configured with honor_labels: false (the default), the infrastructure's namespace label will be renamed to exported_namespace, which would break the Grafana dashboard filter namespace=$chain. Conversely, with honor_labels: true, the app's label would win but the k8s namespace context would be lost. Consider using a more specific label name (e.g., chain or deployment_chain) to avoid ambiguity.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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.

1 participant