-
Notifications
You must be signed in to change notification settings - Fork 46
Telemetry: Trace operations and auth #375
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
Merged
swcollard
merged 8 commits into
feature/telemetry
from
telemetry/operations-trace-metrics
Sep 23, 2025
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5fda361
Trace operation parsing and tool generation
fd25362
Add status code to the http trace
f98215c
Trace Auth with status_code and reason
df98289
Changeset
212f244
Unit tests for auth.rs
db4bbe6
Add raw_operation as a telemetry attribute
5a845cd
Unit test starting a streamable http server
7a14f9d
Rename self to operation_source
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| ### Telemetry: Trace operations and auth - @swcollard PR #375 | ||
|
|
||
| * Adds traces for the MCP server generating Tools from Operations and performing authorization | ||
| * Includes the HTTP status code to the top level HTTP trace |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
|---|---|---|
|
|
@@ -193,15 +193,27 @@ impl Starting { | |
| //start OpenTelemetry trace on incoming request | ||
| .layer(OtelAxumLayer::default()) | ||
| // Add tower-http tracing layer for additional HTTP-level tracing | ||
| .layer(TraceLayer::new_for_http().make_span_with( | ||
| |request: &axum::http::Request<_>| { | ||
| tracing::info_span!( | ||
| "mcp_server", | ||
| method = %request.method(), | ||
| uri = %request.uri(), | ||
| ) | ||
| }, | ||
| )); | ||
| .layer( | ||
| TraceLayer::new_for_http() | ||
| .make_span_with(|request: &axum::http::Request<_>| { | ||
| tracing::info_span!( | ||
| "mcp_server", | ||
| method = %request.method(), | ||
| uri = %request.uri(), | ||
| status = tracing::field::Empty, | ||
DaleSeo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ) | ||
| }) | ||
| .on_response( | ||
| |response: &axum::http::Response<_>, | ||
| _latency: std::time::Duration, | ||
| span: &tracing::Span| { | ||
| span.record( | ||
| "status", | ||
| tracing::field::display(response.status()), | ||
| ); | ||
| }, | ||
| ), | ||
| ); | ||
|
|
||
| // Add health check endpoint if configured | ||
| if let Some(health_check) = health_check.filter(|h| h.config().enabled) { | ||
|
|
@@ -297,3 +309,49 @@ async fn health_endpoint( | |
|
|
||
| Ok((status_code, Json(json!(health)))) | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use http::HeaderMap; | ||
| use url::Url; | ||
|
|
||
| use crate::health::HealthCheckConfig; | ||
|
|
||
| use super::*; | ||
|
|
||
| #[tokio::test] | ||
| async fn start_basic_server() { | ||
|
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. 👍 |
||
| let starting = Starting { | ||
| config: Config { | ||
| transport: Transport::StreamableHttp { | ||
| auth: None, | ||
| address: "127.0.0.1".parse().unwrap(), | ||
| port: 7799, | ||
| stateful_mode: false, | ||
| }, | ||
| endpoint: Url::parse("http://localhost:4000").expect("valid url"), | ||
| mutation_mode: MutationMode::All, | ||
| execute_introspection: true, | ||
| headers: HeaderMap::new(), | ||
| validate_introspection: true, | ||
| introspect_introspection: true, | ||
| search_introspection: true, | ||
| introspect_minify: false, | ||
| search_minify: false, | ||
| explorer_graph_ref: None, | ||
| custom_scalar_map: None, | ||
| disable_type_description: false, | ||
| disable_schema_description: false, | ||
| disable_auth_token_passthrough: false, | ||
| search_leaf_depth: 5, | ||
| index_memory_bytes: 1024 * 1024 * 1024, | ||
| health_check: HealthCheckConfig::default(), | ||
| }, | ||
| schema: Schema::parse_and_validate("type Query { hello: String }", "test.graphql") | ||
| .expect("Valid schema"), | ||
| operations: vec![], | ||
| }; | ||
| let running = starting.start(); | ||
| assert!(running.await.is_ok()); | ||
| } | ||
| } | ||
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
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.
Cool! 👍