Skip to content

Conversation

@daniel-lxs
Copy link
Member

@daniel-lxs daniel-lxs commented Dec 15, 2025

Summary

Add telemetry error capture to the xAI provider, following the same pattern established in PR #10073 for OpenRouter.

Changes

  • Import TelemetryService from @roo-code/telemetry
  • Import ApiProviderError from @roo-code/types
  • In both createMessage() and completePrompt() catch blocks, capture exceptions to telemetry before re-throwing

Pattern Used

try {
  stream = await this.client.chat.completions.create(requestOptions)
} catch (error) {
  const errorMessage = error instanceof Error ? error.message : String(error)
  const apiError = new ApiProviderError(errorMessage, this.providerName, modelId, "createMessage")
  TelemetryService.instance.captureException(apiError)
  throw handleOpenAIError(error, this.providerName)
}

Tests

Added 4 new tests in xai.spec.ts:

  • captures telemetry when createMessage throws an exception
  • captures telemetry when completePrompt throws an exception
  • captures telemetry with correct model ID when using a specific model
  • captures telemetry and still re-throws the error

Related


Important

Add telemetry error capture to xAI provider's createMessage and completePrompt methods, with tests to verify functionality.

  • Behavior:
  • Imports:
    • Import TelemetryService from @roo-code/telemetry.
    • Import ApiProviderError from @roo-code/types.
  • Tests:
    • Add 4 tests in xai.spec.ts to verify telemetry capture in createMessage and completePrompt.
    • Tests ensure correct model ID is captured and errors are re-thrown.

This description was created by Ellipsis for 5b17cf1. You can customize this summary. It will automatically update as commits are pushed.

- Import TelemetryService from @roo-code/telemetry
- Import ApiProviderError from @roo-code/types
- Capture exceptions to telemetry in createMessage() catch block
- Capture exceptions to telemetry in completePrompt() catch block
- Add tests verifying telemetry capture on errors

Follows the same pattern as PR #10073 for OpenRouter.
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. Enhancement New feature or request labels Dec 15, 2025
@roomote
Copy link
Contributor

roomote bot commented Dec 15, 2025

Rooviewer Clock   See task on Roo Cloud

Review complete. No issues found.

The implementation correctly follows the established telemetry error capture pattern from OpenRouter, with proper use of ApiProviderError and TelemetryService. Tests provide comprehensive coverage for both createMessage and completePrompt error scenarios.

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@daniel-lxs
Copy link
Member Author

Closing - changes will be added to PR #10059 instead

@daniel-lxs daniel-lxs closed this Dec 15, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Dec 15, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement New feature or request size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants