:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(ci): emit per-test traces on all in-repo PRs with branch attribute (#64552)
Frank Hamand5341125688bb
diff --git a/.github/scripts/report_test_timings.py b/.github/scripts/report_test_timings.pyindex b6e7f84198ba..457f085dd7a1 100644--- a/.github/scripts/report_test_timings.py+++ b/.github/scripts/report_test_timings.py@@ -350,6 +350,9 @@ def workflow_resource_attributes() -> dict[str, str | int]:attrs["ci.event_name"] = os.environ.get("GITHUB_EVENT_NAME", "")attrs["ci.head_ref"] = os.environ.get("GITHUB_HEAD_REF", "")attrs["ci.base_ref"] = os.environ.get("GITHUB_BASE_REF", "")+ attrs["ci.ref_name"] = os.environ.get("GITHUB_REF_NAME", "")+ # Branch name regardless of event: PR source branch, else the pushed branch.+ attrs["ci.branch"] = os.environ.get("GITHUB_HEAD_REF") or os.environ.get("GITHUB_REF_NAME", "")pr_number = get_pull_request_number()if pr_number is not None:attrs["ci.pr_number"] = pr_numberdiff --git a/.github/scripts/test_report_test_timings.py b/.github/scripts/test_report_test_timings.pyindex ea350ad4970f..b0dc4159095d 100644--- a/.github/scripts/test_report_test_timings.py+++ b/.github/scripts/test_report_test_timings.py@@ -384,10 +384,22 @@ def test_workflow_resource_attributes_includes_query_and_drilldown_fields(assert attrs["ci.event_name"] == "pull_request"assert attrs["ci.head_ref"] == "worktree-per-test-telemetry-junit"assert attrs["ci.base_ref"] == "master"+ assert attrs["ci.branch"] == "worktree-per-test-telemetry-junit"assert attrs["ci.pr_number"] == 57216assert attrs["ci.run_url"] == "https://github.com/PostHog/posthog/actions/runs/25218527467"+def test_workflow_resource_attributes_branch_on_push(monkeypatch: pytest.MonkeyPatch) -> None:+ monkeypatch.delenv("GITHUB_HEAD_REF", raising=False)+ monkeypatch.setenv("GITHUB_EVENT_NAME", "push")+ monkeypatch.setenv("GITHUB_REF_NAME", "master")++ attrs = report_test_timings.workflow_resource_attributes()++ assert attrs["ci.ref_name"] == "master"+ assert attrs["ci.branch"] == "master"++# ---------- trace id ----------diff --git a/.github/workflows/ci-backend.yml b/.github/workflows/ci-backend.ymlindex d660b444f449..ae9d478800cc 100644--- a/.github/workflows/ci-backend.yml+++ b/.github/workflows/ci-backend.yml@@ -3020,15 +3020,14 @@ jobs:runs-on: ubuntu-latestcontinue-on-error: truetimeout-minutes: 10- # Master pushes always; PRs only when labelled `capture-test-timings`. Skip forks (no secrets access).+ # Master pushes and all in-repo PRs. Skip forks (no secrets access).if: >-always() &&github.repository == 'PostHog/posthog' &&((github.event_name != 'pull_request' && github.ref == 'refs/heads/master') ||(github.event_name == 'pull_request' &&- github.event.pull_request.head.repo.full_name == 'PostHog/posthog' &&- contains(github.event.pull_request.labels.*.name, 'capture-test-timings'))+ github.event.pull_request.head.repo.full_name == 'PostHog/posthog'))steps:# Labelled PRs run the trusted base parser, so the same PR can't swap the script that receives secrets.