Commit b0c9501
authored
feat: add GitHub Action usage metrics for telemetry (#475)
## Description
This PR implements the necessary infrastructure in the
\`run-gemini-cli\` GitHub Action to support the Gemini CLI usage metrics
(P0 requirements).
It aligns with the core CLI telemetry changes introduced in
[google-gemini/gemini-cli#21129](google-gemini/gemini-cli#21129).
### Changes Made:
* **Strongly-Typed Telemetry Tracking:** Replaced the generic
\`github_item_number\` with three specific inputs: \`github_pr_number\`,
\`github_issue_number\`, and \`github_custom_tracking_id\`. This ensures
that Pull Requests, Issues, and custom batch IDs are logged to distinct
fields, providing maximum accuracy for downstream analytics without
overlapping ID spaces.
* **Installation Telemetry:** Added \`GH_WORKFLOW_NAME\`,
\`GH_PR_NUMBER\`, \`GH_ISSUE_NUMBER\`, and \`GH_CUSTOM_TRACKING_ID\` to
the \`Install Gemini CLI\` step to ensure extension installations are
properly tracked.
* **OTEL Collector Enhancement:** Updated the
\`scripts/collector-gcp.yaml.template\` to include specific resource
attributes for \`github.pr.number\`, \`github.issue.number\`, and
\`github.custom_tracking.id\`.
* **Example Workflow Updates:** Updated all example workflows (Review,
Triage, Assistant, Scheduled Triage) to explicitly pass the correct IDs
to the action, improving clarity and ensuring accurate telemetry.
### Example Telemetry Scenarios
Because the CLI appends these context fields to the \`baseMetadata\` of
all events (API Request, Response, Error), downstream analytics can
perfectly distinguish and count unique issues vs. PRs based on the
specific fields.
#### Scenario A: Automated PR Review
When PR 42 triggers the \`gemini-review\` workflow, the CLI logs:
```json
{
\"event_name\": \"api_request\",
\"event_metadata\": [
[
{ \"gemini_cli_key\": 130, \"value\": \"gemini-review\" },
{ \"gemini_cli_key\": 172, \"value\": \"pull_request\" },
{ \"gemini_cli_key\": 173, \"value\": \"42\" } // GH_PR_NUMBER
]
]
}
```
*Analysts can count \`DISTINCT gh_pr_number WHERE gh_workflow_name LIKE
'%review%'\` to satisfy the P0 PR metric.*
#### Scenario B: Automated Issue Triage
When Issue 88 triggers the \`gemini-triage\` workflow, the CLI logs:
```json
{
\"event_name\": \"api_request\",
\"event_metadata\": [
[
{ \"gemini_cli_key\": 130, \"value\": \"gemini-triage\" },
{ \"gemini_cli_key\": 172, \"value\": \"issues\" },
{ \"gemini_cli_key\": 174, \"value\": \"88\" } // GH_ISSUE_NUMBER
]
]
}
```
*Analysts can count \`DISTINCT gh_issue_number WHERE gh_workflow_name
LIKE '%triage%' AND gh_event_name = 'issues'\` to satisfy the P0
Automated Issue metric.*
#### Scenario C: Scheduled Batch Triage
When a cron job runs and triages 3 issues (IDs 101, 102, 103) in a
single CLI invocation, the CLI logs:
```json
{
\"event_name\": \"api_request\",
\"event_metadata\": [
[
{ \"gemini_cli_key\": 130, \"value\": \"gemini-scheduled-triage\" },
{ \"gemini_cli_key\": 172, \"value\": \"schedule\" },
{ \"gemini_cli_key\": 175, \"value\": \"101,102,103\" } // GH_CUSTOM_TRACKING_ID
]
]
}
```
*Analysts can split the \`gh_custom_tracking_id\` string by commas to
count exactly 3 unique issues processed during a scheduled invocation.*
## Related Issues
* Fixes P0 metrics requirements for GitHub Action usage.
* Depends on
[google-gemini/gemini-cli#21129](google-gemini/gemini-cli#21129)1 parent d87bfa2 commit b0c9501
7 files changed
Lines changed: 42 additions & 0 deletions
File tree
- examples/workflows
- gemini-assistant
- issue-triage
- pr-review
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
94 | 102 | | |
95 | 103 | | |
96 | 104 | | |
| |||
231 | 239 | | |
232 | 240 | | |
233 | 241 | | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
234 | 246 | | |
235 | 247 | | |
236 | 248 | | |
| |||
414 | 426 | | |
415 | 427 | | |
416 | 428 | | |
| 429 | + | |
| 430 | + | |
417 | 431 | | |
418 | 432 | | |
419 | 433 | | |
| |||
440 | 454 | | |
441 | 455 | | |
442 | 456 | | |
| 457 | + | |
| 458 | + | |
443 | 459 | | |
444 | 460 | | |
445 | 461 | | |
| |||
490 | 506 | | |
491 | 507 | | |
492 | 508 | | |
| 509 | + | |
| 510 | + | |
493 | 511 | | |
494 | 512 | | |
495 | 513 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
69 | 73 | | |
70 | 74 | | |
71 | 75 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
71 | 75 | | |
72 | 76 | | |
73 | 77 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
85 | 88 | | |
86 | 89 | | |
87 | 90 | | |
| |||
109 | 112 | | |
110 | 113 | | |
111 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
112 | 118 | | |
113 | 119 | | |
114 | 120 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
| 83 | + | |
82 | 84 | | |
83 | 85 | | |
84 | 86 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
| 70 | + | |
69 | 71 | | |
70 | 72 | | |
71 | 73 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
15 | 21 | | |
16 | 22 | | |
17 | 23 | | |
| |||
0 commit comments