instrumenting-first-party-metrics
Skill by PostHog
Guides PostHog engineers to instrument PostHog's own code with counters, gauges and histograms that land in the PostHog Metrics product. Covers the SDK path, the OTel fallback, version gates and how to check that metrics arrive.
Install instrumenting-first-party-metrics
Built from the published package, never by AI.
git clone --depth 1 https://github.com/PostHog/posthog /tmp/posthog && mkdir -p ~/.claude/skills && cp -r /tmp/posthog/.agents/skills/instrumenting-first-party-metrics ~/.claude/skills/instrumenting-first-party-metricsRun in your terminal. Claude Code loads skills from ~/.claude/skills automatically.
Step-by-step: install instrumenting-first-party-metrics in Claude Code
git clone --depth 1 https://github.com/PostHog/posthog /tmp/posthog && mkdir -p ~/.gemini/antigravity-cli/skills && cp -r /tmp/posthog/.agents/skills/instrumenting-first-party-metrics ~/.gemini/antigravity-cli/skills/instrumenting-first-party-metricsAntigravity CLI loads skills from ~/.gemini/antigravity-cli/skills, or .agents/skills for one project.
Step-by-step: install instrumenting-first-party-metrics in Antigravity CLI
Skills can run scripts on your machine. Some need an API key: check the README.
About
This skill tells an AI assistant how to add application metrics from PostHog's own code into the posthog.metrics table and Metrics UI, the same way customers do. It records counters, gauges and histograms through the posthog.metrics SDK when the pinned version supports it, and falls back to the internal OTel factory in the monorepo when it does not. It lists the version gates: posthog-python 7.23.0, posthog-node 5.43.0 and posthog-js about 1.399.0.
It warns that the OTel fallback records nothing from Temporal workers, because the export variables are set only on the web deployment. It explains how to confirm arrival, allowing about one minute of ingestion lag, using MCP metric-names-list and query-metrics or SQL. It is for PostHog engineers working in the monorepo (web, Celery, Temporal) or other PostHog-owned services.
Written from the project's SKILL.md and checked against it.
What it can do
- Choose the metrics pathPicks the SDK or OTel fallback based on the environment and pinned versions.
- Check version gatesCompares the pinned posthog-python, posthog-node and posthog-js versions against the minimum that ships posthog.metrics.
- Record counters, gauges and histogramsShows SDK and OTel factory call patterns with names, units and attributes.
- Mirror existing Prometheus instrumentsUses twin helpers so an existing Grafana series and a Metrics product series stay in step.
- Validate metric arrivalUses metric-names-list and query-metrics, or a SQL query on posthog.metrics, to confirm metrics arrive.
- Guide unit testsExplains how to test OTel and SDK instrumentation without hitting the network.
What you need
- PostHog monorepo or a PostHog-owned service
- posthog-python 7.23.0 or later for the SDK path
- posthog-node 5.43.0 or later for Node SDK use
- MCP access to query metrics for arrival checks
Try asking
- Add a counter for invoices processed in our Celery task
- Check whether our pinned SDK supports posthog.metrics
- Show me how to record a job duration histogram in ms
Good to know
- The OTel fallback records nothing from Temporal worker activities.
- Metrics take about one minute to arrive because of ingestion lag.
- In monorepo DEBUG and TEST runs the SDK path records nothing locally, by design.
Security check
ANo download-and-run commands, hidden instructions or signs of sending keys out were found.
Checked automatically: .agents/skills/instrumenting-first-party-metrics/SKILL.md. This looks for known risky patterns and is not a full audit. How grades work
Inside the skill
-
SKILL.md9 KB
Alternatives to instrumenting-first-party-metrics
All alternatives →Runs a 7-stage workflow for auditing, cleaning up and reviewing GitHub repositories, plus competitor analysis. Written for developers who want a repo checked for secrets, junk files and documentation gaps.
Teaches an AI assistant to build, debug and explain Gradio web UIs and ML demos in Python. It covers the core API, components, event listeners, layouts and the MCP server option. Aimed at Python developers who work with Gradio.
Recommends menus, buttons, toolbars and disclosure controls for Apple platforms using Human Interface Guidelines conventions. Built for developers and designers making iOS, iPadOS, macOS or visionOS interfaces. Checks existing project design context before asking questions.
Creates production-ready FastAPI project structures with async patterns, dependency injection, and error handling. It is for developers starting new FastAPI applications or backend API projects.
Analyzes Android apps to find user workflows to expose as AppFunctions, so AI agents and system shortcuts can run them without opening the app UI. Generates Kotlin code and refines KDoc for Android developers.
Creates, edits, validates and runs Agent QA tests, suites and hooks through MCP or CLI. It keeps canonical IDs and schema contracts intact, for developers and QA teams using Agent QA.
Compare with openclaw-github-repo-commander, gradio or hig-components-menus
instrumenting-first-party-metrics: common questions
Does the SDK path work with older posthog-python versions?
posthog.metrics shipped in posthog-python 7.23.0. Below that version, the source says to use the OTel fallback until the dependency bump lands.
Why do metrics from Temporal workers not show up?
OTEL_METRICS_EXPORT_URL and token are set only on the web deployment, so the OTel factory binds a no-op meter on workers.
Which project receives the metrics?
The SDK path in the monorepo sends to the dogfood US project. The internal OTel path sends to the project that OTEL_METRICS_EXPORT_TOKEN points at.
How do I install instrumenting-first-party-metrics?
Run the command above to copy the skill into ~/.claude/skills/. Claude Code picks it up automatically.
Is instrumenting-first-party-metrics free?
The code is published under the NOASSERTION licence. The service it connects to may have its own pricing.
Is instrumenting-first-party-metrics safe to use?
It scores 83 of 100. Grades: maintenance A, licence F, quality A. Security check: grade A, no risky patterns found in the files checked. Review the code before you install. How grades work.
What are alternatives to instrumenting-first-party-metrics?
Similar skills: openclaw-github-repo-commander, gradio, hig-components-menus, fastapi-templates.
