feat(observability): add MCP tool name logging in access log
Some checks failed
CI / build-and-test (push) Failing after -32m45s

* Include tool name from request in access log entries
* Update user agent header in HTTP requests
* Add tests for MCP tool name logging
This commit is contained in:
2026-04-21 22:35:42 +02:00
parent 9a9fa4f384
commit 512b16f8fe
6 changed files with 111 additions and 20 deletions

View File

@@ -9,7 +9,7 @@ import (
func TestFromRequestPrefersXRealIP(t *testing.T) {
req := httptest.NewRequest(http.MethodGet, "/", nil)
req.RemoteAddr = "10.0.0.10:5555"
req.Header.Set("X-Forwarded-Host", "proxy.example.com")
req.Header.Set("X-Forwarded-For", "198.51.100.1")
req.Header.Set("X-Real-IP", "203.0.113.10")
if got := FromRequest(req); got != "203.0.113.10" {
@@ -17,16 +17,6 @@ func TestFromRequestPrefersXRealIP(t *testing.T) {
}
}
func TestFromRequestUsesXForwardedHostWhenRealIPMissing(t *testing.T) {
req := httptest.NewRequest(http.MethodGet, "/", nil)
req.RemoteAddr = "10.0.0.10:5555"
req.Header.Set("X-Forwarded-Host", "203.0.113.22")
if got := FromRequest(req); got != "203.0.113.22" {
t.Fatalf("FromRequest() = %q, want %q", got, "203.0.113.22")
}
}
func TestFromRequestUsesXForwardedForFirstValue(t *testing.T) {
req := httptest.NewRequest(http.MethodGet, "/", nil)
req.RemoteAddr = "10.0.0.10:5555"