-
Notifications
You must be signed in to change notification settings - Fork 143
fix: make mcp span names informative #1288
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,6 @@ import ( | |
|
|
||
| "github.com/modelcontextprotocol/go-sdk/mcp" | ||
| "github.com/stretchr/testify/require" | ||
| v1 "go.opentelemetry.io/proto/otlp/trace/v1" | ||
|
|
||
| "github.com/envoyproxy/ai-gateway/internal/filterapi" | ||
| "github.com/envoyproxy/ai-gateway/internal/testing/testotel" | ||
|
|
@@ -241,16 +240,18 @@ func (m *mcpEnv) newSession(t *testing.T) *mcpSession { | |
| ret.session, err = m.client.Connect(t.Context(), &mcp.StreamableClientTransport{Endpoint: m.baseURL}, nil) | ||
| require.NoError(t, err) | ||
| span := m.collector.TakeSpan() | ||
| require.Equal(t, "mcp.request", span.Name) | ||
| require.Equal(t, v1.Span_SPAN_KIND_CLIENT, span.Kind) | ||
|
|
||
| t.Log("created new MCP session with ID ", ret.session.ID(), ", first span: ", span.String()) | ||
| require.NotNil(t, span) | ||
| requireMCPSpan(t, span, "Initialize", map[string]string{ | ||
| "mcp.method.name": "initialize", | ||
| "mcp.client.name": "demo-http-client", | ||
| "mcp.client.title": "", | ||
| "mcp.client.version": "0.1.0", | ||
| }) | ||
|
|
||
| // **NOTE*** Do not add any direct access to the in-memory server session. Otherwise, the tests will result in | ||
| // not being able to run in end-to-end tests. The test code must solely operate through the client side sessions. | ||
| t.Cleanup(func() { | ||
| require.NoError(t, ret.session.Close()) | ||
| _ = ret.session.Close() | ||
|
Contributor
Author
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. should be a linter for this somewhere. @anuraaga come across any that notice when accidental use of require.RequreXX n a cleanup? t.LogXX is fine, but require is bad
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. There's a close one but no cigar https://github.com/Antonboom/testifylint?tab=readme-ov-file#go-require Probably not too hard to adapt that to apply to both cases though
Contributor
Author
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. Cc @nacx |
||
| m.mux.Lock() | ||
| defer m.mux.Unlock() | ||
| delete(m.sessions, ret.session.ID()) | ||
|
|
||
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.
cc @nacx