Skip to content

Conversation

@codefromthecrypt
Copy link
Contributor

@codefromthecrypt codefromthecrypt commented Oct 7, 2025

Description

Before everything was vaguely "mcp.request" which is not untrue, but not helpful. There are plenty of low-cardinality choices for span or metric names and the req.Method is the most intuitive. This uses the same naming conventions as mcp-go

image

@codefromthecrypt codefromthecrypt requested a review from a team as a code owner October 7, 2025 01:35
@codecov-commenter
Copy link

codecov-commenter commented Oct 7, 2025

Codecov Report

❌ Patch coverage is 91.17647% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.49%. Comparing base (7c37901) to head (615d4eb).

Files with missing lines Patch % Lines
internal/tracing/mcp.go 93.93% 2 Missing ⚠️
internal/mcpproxy/handlers.go 0.00% 1 Missing ⚠️

❌ Your project status has failed because the head coverage (77.49%) is below the target coverage (86.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1288      +/-   ##
==========================================
+ Coverage   77.44%   77.49%   +0.04%     
==========================================
  Files         123      123              
  Lines       15651    15684      +33     
==========================================
+ Hits        12121    12154      +33     
  Misses       2901     2901              
  Partials      629      629              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codefromthecrypt
Copy link
Contributor Author

Screenshot 2025-10-07 at 9 42 20 AM

Copy link
Member

@mathetake mathetake left a comment

Choose a reason for hiding this comment

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

1000% makes sense

@mathetake mathetake enabled auto-merge (squash) October 7, 2025 02:54
auto-merge was automatically disabled October 7, 2025 03:18

Head branch was pushed to by a user without write access

@codefromthecrypt
Copy link
Contributor Author

changed to re-use MCP go naming conventions as that also matches the openinference names of these spans.

@codefromthecrypt
Copy link
Contributor Author

now envoy ai gateway generated spans look similar!

Screenshot 2025-10-07 at 11 24 54 AM

@codefromthecrypt
Copy link
Contributor Author

🤞 last commit deflakes

@codefromthecrypt
Copy link
Contributor Author

wasn't enough to deflake I am flying to NYC now. appreciate if someone can take over otherwise will wait a while

@mathetake
Copy link
Member

unified trace looking coooooooooooooooooooool

Copy link
Member

@nacx nacx left a comment

Choose a reason for hiding this comment

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

Nice!

@codefromthecrypt
Copy link
Contributor Author

I will rewrite the test so that not all tests also do tracing because it is too hairy ;)

@codefromthecrypt
Copy link
Contributor Author

ok brutal work, but hopefully deflaked

// 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()
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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

Copy link
Contributor

Choose a reason for hiding this comment

The 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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cc @nacx

{name: "Complete", testFn: testComplete},
}

func TestMCP(t *testing.T) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I broke these up vs having triple nested subtests

Copy link
Contributor Author

@codefromthecrypt codefromthecrypt left a comment

Choose a reason for hiding this comment

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

made notes on the edge cases

require.NoError(t, err)
require.False(t, res.IsError)
// Consume the span from the cleanup operation.
_ = m.collector.TakeSpan()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this bit hard

case <-time.After(time.Microsecond * 500):
cancel()
// Wait for the goroutine to complete so its span doesn't leak to the next test.
<-doneCh
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this also bit hard ;)

@codefromthecrypt
Copy link
Contributor Author

most of why this test is so hard is we share resources including otel everywhere in this file. It would probably be better to have two tests at some point. one that does all this behavioural stuff. The other simply tests each op creates the span expected. Combining both made this a huge amount of work to fix

Copy link
Member

@mathetake mathetake left a comment

Choose a reason for hiding this comment

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

1000% makes sense

Signed-off-by: Takeshi Yoneda <[email protected]>
@mathetake mathetake enabled auto-merge (squash) October 7, 2025 21:46
}
err = m.handleSetLoggingLevel(ctx, s, w, msg, p, span)
case "ping":
// Ping is intentionally not traced as it's a lightweight health check.
Copy link
Member

Choose a reason for hiding this comment

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

cc @nacx

@codefromthecrypt
Copy link
Contributor Author

one sec I found I didn't assert our span events.

@mathetake mathetake disabled auto-merge October 7, 2025 22:00
@mathetake
Copy link
Member

you have my one sec!

Signed-off-by: Adrian Cole <[email protected]>
@codefromthecrypt
Copy link
Contributor Author

k done :)

}
event.Attributes = filteredAttrs
}
require.Empty(t, cmp.Diff(expectedEvents, span.Events, protocmp.Transform()))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ps this is my favorite trick in tests!

@mathetake mathetake enabled auto-merge (squash) October 7, 2025 22:12
@mathetake mathetake merged commit 577cc65 into envoyproxy:main Oct 7, 2025
31 checks passed
@codefromthecrypt codefromthecrypt deleted the mcp-names branch October 7, 2025 22:52
@codefromthecrypt
Copy link
Contributor Author

thanks for the merge. since latest commit is pushed to docker, the new elastcisearch example can see this new data policy! elastic/observability-examples#90

@codefromthecrypt
Copy link
Contributor Author

Screenshot 2025-10-08 at 7 04 15 AM

nutanix-Hrushikesh pushed a commit to nutanix-Hrushikesh/ai-gateway that referenced this pull request Oct 16, 2025
**Description**

Before everything was vaguely "mcp.request" which is not untrue, but not
helpful. There are plenty of low-cardinality choices for span or metric
names and the `req.Method` is the most intuitive. This uses the same
naming conventions as mcp-go

---------

Signed-off-by: Adrian Cole <[email protected]>
Signed-off-by: Hrushikesh Patil <[email protected]>
nutanix-Hrushikesh pushed a commit to nutanix-Hrushikesh/ai-gateway that referenced this pull request Oct 16, 2025
**Description**

Before everything was vaguely "mcp.request" which is not untrue, but not
helpful. There are plenty of low-cardinality choices for span or metric
names and the `req.Method` is the most intuitive. This uses the same
naming conventions as mcp-go

---------

Signed-off-by: Adrian Cole <[email protected]>
Signed-off-by: Hrushikesh Patil <[email protected]>
nutanix-Hrushikesh pushed a commit to nutanix-Hrushikesh/ai-gateway that referenced this pull request Oct 16, 2025
**Description**

Before everything was vaguely "mcp.request" which is not untrue, but not
helpful. There are plenty of low-cardinality choices for span or metric
names and the `req.Method` is the most intuitive. This uses the same
naming conventions as mcp-go

---------

Signed-off-by: Adrian Cole <[email protected]>
Signed-off-by: Hrushikesh Patil <[email protected]>
missBerg pushed a commit to missBerg/ai-gateway that referenced this pull request Dec 20, 2025
**Description**

Before everything was vaguely "mcp.request" which is not untrue, but not
helpful. There are plenty of low-cardinality choices for span or metric
names and the `req.Method` is the most intuitive. This uses the same
naming conventions as mcp-go

---------

Signed-off-by: Adrian Cole <[email protected]>
Signed-off-by: Erica Hughberg <[email protected]>
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.

5 participants