Skip to content

Add error telemetry for every GH API call#8706

Merged
alexr00 merged 1 commit intomainfrom
alexr00/monetary-hoverfly
Apr 27, 2026
Merged

Add error telemetry for every GH API call#8706
alexr00 merged 1 commit intomainfrom
alexr00/monetary-hoverfly

Conversation

@alexr00
Copy link
Copy Markdown
Member

@alexr00 alexr00 commented Apr 27, 2026

No description provided.

Copilot AI review requested due to automatic review settings April 27, 2026 12:55
@alexr00 alexr00 enabled auto-merge (squash) April 27, 2026 12:55
@alexr00 alexr00 self-assigned this Apr 27, 2026
@alexr00 alexr00 changed the title Add error telemetry for ever GH API call Add error telemetry for every GH API call Apr 27, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 a pr.apiCallFailed telemetry error event when REST/GraphQL calls reject.
  • Moves and re-exports getErrorCode() (and helper typing) into loggingOctokit.ts, updating githubRepository.ts to import it from there.
  • Hooks logApiError() into LoggingApolloClient.query, LoggingApolloClient.mutate, and LoggingOctokit.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

Comment on lines +65 to +71
const message = typeof e.message === 'string' ? e.message : '';
if (e.name !== 'Error') {
return message ? `${e.name}: ${message}` : e.name;
}
if (message) {
return message;
}
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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;

Copilot uses AI. Check for mistakes.
@alexr00 alexr00 merged commit f2befce into main Apr 27, 2026
10 checks passed
@alexr00 alexr00 deleted the alexr00/monetary-hoverfly branch April 27, 2026 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants