Skip to content

Conversation

@AlitzelMendez
Copy link
Member

Adds Application Insights telemetry to the AutoReview controller endpoints (/upload and /create) to help diagnose failures that are difficult to investigate with current logging.

Background

A user reported receiving HTTP 520 errors when uploading packages to APIView. Investigation revealed that our server returned HTTP 400, but we had insufficient logging to determine the root cause. The request failed before reaching the parser (12ms response time vs ~10s for successful parsing), indicating the failure occurred during request processing rather than code file parsing.

Copy link
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

Adds Application Insights telemetry to AutoReview failure paths to improve diagnostics for /autoreview/upload and /autoreview/create.

Changes:

  • Injects TelemetryClient into AutoReviewController and tracks exceptions with request context properties.
  • Emits an event when /upload is hit without a file.
  • Tracks a failure event when external language parser processes exit non-zero, including truncated stdout/stderr.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/dotnet/APIView/APIViewWeb/LeanControllers/AutoReviewController.cs Adds AI telemetry to /upload and /create exception paths and a “no file provided” event.
src/dotnet/APIView/APIViewWeb/Languages/LanguageProcessor.cs Adds AI telemetry for external parser process failures (non-zero exit code).
Comments suppressed due to low confidence (1)

src/dotnet/APIView/APIViewWeb/LeanControllers/AutoReviewController.cs:99

  • The fall-through path logs "UploadAutoReview_NoFileProvided" and returns a 500, but this branch is also hit when a file was provided and CreateAutomaticRevisionAsync returns null (or apiRevision stays null for other reasons). Please split the control flow so: (1) missing file returns a 400 BadRequest (and logs a "NoFileProvided" event), and (2) apiRevision == null returns a 500 with an accurate error and telemetry.
        _telemetryClient.TrackEvent("UploadAutoReview_NoFileProvided");
        return StatusCode(statusCode: StatusCodes.Status500InternalServerError, new
        {
            error = "Failed to create API review. No file provided."

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.

1 participant