Repository navigation
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the log_sse_event() method in the OtelEventManager to no longer accept a closure, simplifying its interface and moving timing logic to the caller sites.
- Simplified
log_sse_event()signature by removing generic closure parameters - Moved timing and response handling from the method to caller sites
- Updated all call sites to handle timing locally before calling the logging method
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| codex-rs/otel/src/otel_event_manager.rs | Refactored log_sse_event() to accept response and duration directly instead of executing a closure |
| codex-rs/core/src/client.rs | Updated call site to handle timing and pass results to simplified logging method |
| codex-rs/core/src/chat_completions.rs | Updated call site to handle timing and pass results to simplified logging method |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
|
||
| match response { | ||
| Ok(Some(Ok(ref sse))) => { | ||
| Ok(Some(Ok(sse))) => { |
There was a problem hiding this comment.
Removing the ref keyword changes the ownership semantics. The code now moves sse instead of borrowing it, which could impact performance if StreamEvent is a large struct. Consider keeping the reference to avoid unnecessary moves.
| Ok(Some(Ok(sse))) => { | |
| Ok(Some(Ok(ref sse))) => { |
| } | ||
| Ok(Some(Err(ref error))) => { | ||
| Ok(Some(Err(error))) => { | ||
| self.sse_event_failed(None, duration, error); |
There was a problem hiding this comment.
Removing the ref keyword changes the ownership semantics. The code now moves error instead of borrowing it, which could impact performance if the error type is large. Consider keeping the reference to avoid unnecessary moves.
| self.sse_event_failed(None, duration, error); | |
| self.sse_event_failed(None, duration, &error); |
Unlikely fix for #4381, but worth a shot given that #2103 changed around the same time.