Skip to content

Conversation

@howardjohn
Copy link
Collaborator

No description provided.

@howardjohn howardjohn requested a review from a team as a code owner October 6, 2025 21:26
Copilot AI review requested due to automatic review settings October 6, 2025 21:26
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

This PR adds a new 'reason' tag to HTTP metrics to provide better observability into why requests failed or succeeded. The change introduces a ProxyResponseReason enum that categorizes different response scenarios and integrates it into the telemetry system.

  • Introduces ProxyResponseReason enum with categories like Upstream, NotFound, Internal, etc.
  • Adds reason field to HTTP metrics labels and request logging
  • Refactors error handling to use the new external authorization error type and removes transformation failure errors

Reviewed Changes

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

Show a summary per file
File Description
crates/agentgateway/src/telemetry/metrics.rs Adds reason field to HTTPLabels struct and reorganizes imports
crates/agentgateway/src/telemetry/log.rs Adds reason field to RequestLog struct and populates it in metrics
crates/agentgateway/src/proxy/mod.rs Introduces ProxyResponseReason enum with Display implementation and mapping logic
crates/agentgateway/src/proxy/httpproxy.rs Integrates reason tracking and removes transformation error handling
crates/agentgateway/src/http/transformation_cel_tests.rs Updates test calls to match new transformation API
crates/agentgateway/src/http/transformation_cel.rs Removes error returns from transformation methods
crates/agentgateway/src/http/ext_authz.rs Updates to use new ExternalAuthorizationFailed error type

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +93 to +94
/// The upstream request failed
UpstreamFailure,
Copy link

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

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

The UpstreamFailure variant is defined but never used in the as_reason method. All upstream-related errors map to ProxyResponseReason::Upstream instead. Consider removing this unused variant or updating the mapping logic to use it.

Suggested change
/// The upstream request failed
UpstreamFailure,

Copilot uses AI. Check for mistakes.
if let Some(j) = &policies.transformation {
j.apply_request(req, exec.deref().as_ref().map_err(cel_err)?)
.map_err(|_| ProxyError::TransformationFailure)?;
j.apply_request(req, exec.deref().as_ref().map_err(cel_err)?);
Copy link

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

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

The error handling with map_err(cel_err)? is unnecessary since apply_request no longer returns a Result. The call can be simplified to just j.apply_request(req, exec.deref().as_ref().unwrap()).

Suggested change
j.apply_request(req, exec.deref().as_ref().map_err(cel_err)?);
j.apply_request(req, exec.deref().as_ref().unwrap());

Copilot uses AI. Check for mistakes.
.map_err(|_| ProxyError::ProcessingString("failed to build cel context".to_string()))?;
j.apply_request(req, &exec)
.map_err(|_| ProxyError::TransformationFailure)?;
j.apply_request(req, &exec);
Copy link

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

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

Similar to the previous comment, the error handling setup with cel_err closure is defined but no longer needed since apply_request doesn't return errors. The exec variable and error handling can be simplified.

Copilot uses AI. Check for mistakes.
Comment on lines +1292 to +1297
let cel_err = |_| ProxyError::ProcessingString("failed to build cel context".to_string());
if let Some(j) = &self.transformation {
j.apply_response(resp, log.cel.ctx())
.map_err(|_| ProxyError::TransformationFailure)?;
j.apply_response(resp, exec.deref().as_ref().map_err(cel_err)?);
}
if let Some(j) = &self.gateway_transformation {
j.apply_response(resp, log.cel.ctx())
.map_err(|_| ProxyError::TransformationFailure)?;
j.apply_response(resp, exec.deref().as_ref().map_err(cel_err)?);
Copy link

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

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

The cel_err closure is defined but never used since the transformation methods no longer return errors. This dead code should be removed along with the associated error handling.

Copilot uses AI. Check for mistakes.
@howardjohn howardjohn merged commit a147b69 into agentgateway:main Oct 6, 2025
7 checks passed
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