Skip to content

refactor(public-api/v1alpha): derive watchman prefix from METRICS_NAMESPACE#1060

Open
skipi wants to merge 2 commits into
mainfrom
mk/public-api/watchman-metrics-namespace
Open

refactor(public-api/v1alpha): derive watchman prefix from METRICS_NAMESPACE#1060
skipi wants to merge 2 commits into
mainfrom
mk/public-api/watchman-metrics-namespace

Conversation

@skipi

@skipi skipi commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

What

ppl-api (public-api/v1alpha) set its Watchman metric prefix from K8S_NAMESPACE at application start (set_watchman_prefix + restart_app), so its metrics were tagged with the pod's Kubernetes namespace instead of the METRICS_NAMESPACE value every other service uses. That made the env graphite tag non-uniform — ppl-api landed under a different env than the rest of the platform, so the shared per-client request counters (emitted under the same names by several API services so they can be aggregated) split ppl-api away from the others.

This resolves the prefix from METRICS_NAMESPACE in runtime.exs, matching the convention already used by projecthub, secrethub, dashboardhub, guard, and the Go services. The now-dead application-start hook and the Util.Config helper module that existed only for it are removed.

Why runtime.exs

The prefix only depends on a runtime env var, and runtime config is applied before the :watchman application boots — so the value is correct at startup with no need to mutate config and restart the app afterwards.

Note for dashboards / alerts

This relocates existing ppl-api.* metric series from env=<k8s-namespace> to env=<METRICS_NAMESPACE>. Any dashboard or alert keyed on the old env value needs updating after this ships.

🤖 Generated with Claude Code

@github-project-automation github-project-automation Bot moved this to Backlog in Roadmap Jun 15, 2026
@skipi
skipi force-pushed the mk/public-api/watchman-metrics-namespace branch 2 times, most recently from df0658b to 30e2ff2 Compare June 15, 2026 09:33
skipi and others added 2 commits June 15, 2026 13:19
…ESPACE

ppl-api set its Watchman metric prefix from K8S_NAMESPACE at app start
(set_watchman_prefix + restart_app), tagging its metrics with the pod's
k8s namespace instead of the platform-wide METRICS_NAMESPACE every other
service uses. That left the `env` graphite tag non-uniform, so the shared
api.client_usage / api.org_usage series split ppl-api from the rest.

Resolve the prefix from METRICS_NAMESPACE in runtime.exs, matching the
convention used by projecthub/secrethub/dashboardhub/etc., and drop the
now-dead app-start hack plus the Config helper module that existed only
for it.

Note: this relocates existing ppl-api.* series from env=<k8s-namespace>
to env=<METRICS_NAMESPACE> (e.g. s2prod); any dashboard/alert keyed on
the old env value needs updating.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
runtime.exs now sets the :watchman prefix unguarded, so it applies during
mix test too (METRICS_NAMESPACE unset -> "ppl-api.dev"), overriding the
"ppl-api.test" value here. The test.exs prefix was therefore inert and
misleading. Drop it; keep host/port. Matches projecthub, which has no
watchman prefix in its test.exs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@skipi
skipi force-pushed the mk/public-api/watchman-metrics-namespace branch from 30e2ff2 to 95b6201 Compare June 15, 2026 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant