Add error telemetry for every GH API call#8706
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds telemetry for failed GitHub API calls by attaching error handlers to the existing Octokit/Apollo logging wrappers, and centralizes error-code extraction logic for reuse across GitHub telemetry events.
Changes:
- Introduces
RateLogger.logApiError()to emit apr.apiCallFailedtelemetry error event when REST/GraphQL calls reject. - Moves and re-exports
getErrorCode()(and helper typing) intologgingOctokit.ts, updatinggithubRepository.tsto import it from there. - Hooks
logApiError()intoLoggingApolloClient.query,LoggingApolloClient.mutate, andLoggingOctokit.call.
Show a summary per file
| File | Description |
|---|---|
| src/github/loggingOctokit.ts | Adds getErrorCode() and new telemetry emission (pr.apiCallFailed) for rejected REST/GraphQL calls. |
| src/github/githubRepository.ts | Removes local getErrorCode() implementation and imports shared version from loggingOctokit.ts. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 1
| const message = typeof e.message === 'string' ? e.message : ''; | ||
| if (e.name !== 'Error') { | ||
| return message ? `${e.name}: ${message}` : e.name; | ||
| } | ||
| if (message) { | ||
| return message; | ||
| } |
There was a problem hiding this comment.
getErrorCode falls back to returning Error name+message (or just message) when no status/code fields are present. Since this value is sent as the errorCode telemetry property (SystemMetaData) for pr.apiCallFailed and other events, including message can introduce high-cardinality values and may inadvertently capture sensitive data embedded in error messages. Consider restricting this to low-cardinality identifiers only (e.g., HTTP status/statusCode, GraphQL extensions.code, known code values, and possibly name without message), and return undefined/UnknownError otherwise.
| const message = typeof e.message === 'string' ? e.message : ''; | |
| if (e.name !== 'Error') { | |
| return message ? `${e.name}: ${message}` : e.name; | |
| } | |
| if (message) { | |
| return message; | |
| } | |
| return e.name; |
No description provided.