chore(agents): add instrumenting-first-party-metrics skill - #72413
Conversation
Documents the prometheus_client + OtelInstrumentFactory twin pattern for emitting first-party metrics from backend code, so agents stop bolting on OTel SDK setup or env vars that already exist as charts-level deployment config. Covers what is already wired (scraping, multiprocess mode, OTLP push gating), the twin and direct-instrument APIs, reference call sites, and adjacent mechanisms (pushgateway, node twin). Generated-By: PostHog Code Task-Id: 470062dd-05c0-40bf-bfa3-bc89b194121e
|
Hey @DanielVisca! 👋 It looks like your git author email on this PR isn't your
You can fix it for this repo with: git config user.email "you@posthog.com"Or set it globally with |
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
.agents/skills/instrumenting-first-party-metrics/SKILL.md:79
**Verification Excludes Python Metrics**
`bin/verify-metrics-pipe` filters for `logs-ingestion`, `metrics-ingestion`, and `nodejs`, but Python metrics normally use `posthog-python`. Following this step for a Django, Celery, or Temporal metric therefore reports no results even when export works; document a Python-specific check or update the script first.
Reviews (1): Last reviewed commit: "chore(agents): add instrumenting-first-p..." | Re-trigger Greptile |
|
Note 🤖 stamphog reviewed Confirmed via the actual script that greptile's unresolved concern is accurate:
Gate mechanics and policy version
|
|
Thanks for confirming with the script directly. Here's a targeted fix for the "Verifying" section — remove the misleading The key changes:
|
Rewrites the skill to be Metrics-product-first: environment decision table (SDK the customer way, OTel factory as fallback), explicit per-SDK version gates (posthog-python 7.23.0 / posthog-node 5.43.0 / posthog-js ~1.399.0), the bump-ready internal wiring, and a validation section (destination project, dev/test disabled gotchas, query-metrics/SQL arrival checks). Grafana and pushgateway demoted to an adjacent note. Generated-By: PostHog Code Task-Id: 470062dd-05c0-40bf-bfa3-bc89b194121e
|
Reoriented the skill per feedback: it's now Metrics-product-first — environment decision table (SDK the customer way per the public docs, OTel factory only as fallback), explicit per-SDK version gates (posthog-python 7.23.0 / posthog-node 5.43.0 / posthog-js ~1.399.0, with a runtime check for js), what's already wired internally (#72430 + posthog-python#753), and a validation section covering destination project, the disabled-in-DEBUG/TEST gotcha, and arrival checks via |
Generated-By: PostHog Code Task-Id: 470062dd-05c0-40bf-bfa3-bc89b194121e
Generated-By: PostHog Code Task-Id: 934a73f2-8545-4575-b4b2-497a4c181f9c
There was a problem hiding this comment.
Doc-only addition of a new agent skill file; no production code, dependency, or risky-surface changes. The one reviewer concern (bin/verify-metrics-pipe not covering Python) was addressed in the current diff and greptile acknowledged the fix with a 👍.
- 👍 on the PR from greptile-apps[bot], hex-security-app[bot].
Gate mechanics and policy version
| Gate | Result | |
|---|---|---|
| prerequisites | ✓ | all clear |
| deny-list | ✓ | no deny categories matched |
| size | ✓ | 0L, 0F substantive, 74L/1F incl. docs/generated/snapshots — within ceiling |
| tier | ✓ | T1-agent / T1b-small (74L, 1F, single-area, chore) |
| stamphog 2.0.0b3 | .stamphog/policy.yml @ ced1a6a · reviewed head 4229dd4 |
Problem
No skill covers how to emit first-party metrics from this repo's backend code. The canonical pattern (a
prometheus_clientinstrument plus anOtelInstrumentFactorytwin) lives only in theposthog/otel_metrics.pydocstring, three call sites, and internal design docs. Agents hitting this cold discover the OTel SDK and start adding exporters and env vars that already exist as charts-level deployment config.Changes
Adds
.agents/skills/instrumenting-first-party-metrics/SKILL.md, a repo-engineering skill covering::8001scraping,PROMETHEUS_MULTIPROC_DIR, per-PID OTLP provider init and its env-var gatingHow did you test this code?
Doc-only change.
hogli lint:skillscan't run in my sandbox (no flox python), so I validated the frontmatter parses with name and a 496-char description, and confirmed the skill is visible through the.claude/skillssymlink. CI's skills lint covers the rest.Automatic notifications
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Written by Claude (PostHog Code session) after an investigation into how web/celery Prometheus metrics reach the Metrics product, prompted by an agent wrongly insisting env vars were needed. Invoked /writing-skills for conventions. Companion PRs: customer-facing docs in PostHog/posthog.com#18700 and the
instrument-metricsskill family in PostHog/context-mill#255.Created with PostHog Code