-
Notifications
You must be signed in to change notification settings - Fork 14.4k
exec-server: standardize JSON-RPC request spans #31687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
+161
−17
Closed
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -129,7 +129,7 @@ async fn run_connection( | |
| codex_exec_server_protocol::JSONRPCMessage::Request(request) => { | ||
| let request_started_at = Instant::now(); | ||
| if let Some((method, route)) = router.request_route(request.method.as_str()) { | ||
| let request_span = request_span(method, &request); | ||
| let request_span = request_span(method, &request, transport); | ||
| let message = tokio::select! { | ||
| message = route(Arc::clone(&handler), request).instrument(request_span.clone()) => message, | ||
| _ = disconnected_rx.changed() => { | ||
|
|
@@ -160,7 +160,7 @@ async fn run_connection( | |
| drop(request_span); | ||
| } else { | ||
| let method = "unknown"; | ||
| let request_span = request_span(method, &request); | ||
| let request_span = request_span(method, &request, transport); | ||
| if outgoing_tx | ||
| .send(RpcServerOutboundMessage::Error { | ||
| request_id: request.id, | ||
|
|
@@ -244,12 +244,17 @@ async fn run_connection( | |
| fn request_span( | ||
| span_name: &str, | ||
| request: &codex_exec_server_protocol::JSONRPCRequest, | ||
| transport: ConnectionTransport, | ||
| ) -> tracing::Span { | ||
| let method = request.method.as_str(); | ||
| let span = tracing::info_span!( | ||
| "codex.exec_server.request", | ||
| otel.kind = "server", | ||
| otel.name = span_name, | ||
| rpc.system = "jsonrpc", | ||
| rpc.method = method, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NIT: should |
||
| rpc.transport = transport.metric_tag(), | ||
| rpc.request_id = %request.id, | ||
| method, | ||
| result = tracing::field::Empty, | ||
| ); | ||
|
|
@@ -324,6 +329,7 @@ mod tests { | |
| use crate::server::session_registry::SessionRegistry; | ||
|
|
||
| #[test] | ||
| #[serial_test::serial(exec_server_tracing)] | ||
| fn request_span_uses_bounded_name_wire_method_and_inbound_trace_parent() { | ||
| let span_exporter = InMemorySpanExporter::default(); | ||
| let tracer_provider = SdkTracerProvider::builder() | ||
|
|
@@ -351,7 +357,11 @@ mod tests { | |
| params: None, | ||
| trace: Some(trace), | ||
| }; | ||
| let request_span = request_span("unknown", &request); | ||
| let request_span = request_span( | ||
| "unknown", | ||
| &request, | ||
| crate::telemetry::ConnectionTransport::Stdio, | ||
| ); | ||
| request_span.in_scope(|| {}); | ||
| drop(request_span); | ||
| }); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this drops telemetry for the two early admission failures: regular calls can return
PendingRequestLimitExceededbeforecall_inner, and cleanup overflow closes the transport before reaching it too...Both were inside the outer request spans before this change, so saturation is now exactly when this telemetry disappears