You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Introduced a mechanism to collect GitHub API call metrics from
controller logs during E2E tests.
- Added logic to parse structured log entries for API calls at the end
of each test run.
- Stored the collected data, including operation, duration, and status
code, in a structured JSON report.
- Updated the CI workflow to archive the generated reports for analysis
and monitoring.
Signed-off-by: Chmouel Boudjnah <[email protected]>
-`PAC_API_INSTRUMENTATION_DIR` - Optional. When set, E2E tests write per-test JSON reports of GitHub API calls parsed from controller logs to this directory. Useful for analyzing API usage and rate limits. Example: `export PAC_API_INSTRUMENTATION_DIR=/tmp/api-instrumentation`.
62
+
61
63
You don't need to configure all of those if you restrict running your e2e tests to a subset.
62
64
63
65
## Running
@@ -155,6 +157,57 @@ The `hack/gh-workflow-ci.sh` script contains several functions that assist in th
155
157
156
158
The script filters tests by category using pattern matching on test function names.
157
159
160
+
> [!NOTE]
161
+
> For details on how API call metrics are generated and archived as artifacts, see [API Instrumentation (optional)](#api-instrumentation-optional).
162
+
163
+
### API Instrumentation (optional)
164
+
165
+
To help debug and analyze GitHub API usage during E2E runs, tests can emit
166
+
structured JSON reports of API calls when the environment variable
167
+
`PAC_API_INSTRUMENTATION_DIR` is set.
168
+
169
+
> [!NOTE]
170
+
> Currently supported only for GitHub (both GitHub App and GitHub webhook flows). Support for other providers is planned.
171
+
172
+
- Set `PAC_API_INSTRUMENTATION_DIR` to a writable path before running tests,
- Each test produces a file named like `YYYY-MM-DDTHH-MM-SS_<test_name>.json` containing summary fields and an array of API calls (operation, duration_ms, url_path, status_code, rate_limit_remaining, provider, repo).
176
+
- In CI, this variable defaults to `/tmp/api-instrumentation` and `hack/gh-workflow-ci.sh collect_logs` copies the directory into the uploaded artifacts.
177
+
178
+
Log source details:
179
+
180
+
- Parses controller pod logs from the `pac-controller` container.
181
+
- Uses label selector `app.kubernetes.io/name=controller` (or `ghe-controller` when testing against GHE).
182
+
- Considers only log lines after the last occurrence of `github-app: initialized OAuth2 client`.
183
+
- Matches lines containing `GitHub API call completed` and extracts the embedded JSON payload.
0 commit comments