feat(ci_visibility): add test_session telemetry metric with provider and auto_injected tags#17696
feat(ci_visibility): add test_session telemetry metric with provider and auto_injected tags#17696
Conversation
…and auto_injected tags Adds a new `test_session` count metric emitted once per session with `provider` and `auto_injected` tags, reducing cardinality versus including these tags on the per-test `event_finished` metric. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codeowners resolved as |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4c3d81d767
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| TelemetryAPI.get().record_test_session( | ||
| ci_provider_name=self.manager.env_tags.get(CITag.PROVIDER_NAME), | ||
| is_auto_injected=self.manager.is_auto_injected, | ||
| ) |
There was a problem hiding this comment.
Emit test_session metric only from xdist main process
In pytest-xdist runs, pytest_sessionfinish executes in every worker and in the controller process, but record_test_session is called before the if not self.is_xdist_worker guard. This makes the new test_session counter scale with worker count (e.g., 9 emissions for 8 workers) instead of once per logical test session, which skews the provider/auto-injection telemetry this metric is meant to represent.
Useful? React with 👍 / 👎.
Summary
test_sessioncount metric emitted once per test session withproviderandauto_injectedtagsevent_finishedmetricrecord_session_finishedTest plan
record_test_sessionwith provider and auto_injected tagsMotivation
Per CI Visibility telemetry RFC: a dedicated low-cardinality
test_sessionmetric allows tracking CI provider distribution and auto-injection without inflatingevent_created/event_finishedtag cardinality.🤖 Generated with Claude Code