Repository navigation
test: exercise server-edition observability user_id/profile label values (MCP-3207) - #752
Conversation
…ues (MCP-3207)
The v0.45.0 QA pass (OBS-05) code-verified the server-edition tool-call
telemetry label injection (editionToolCallAttributes, MCP-32) but never drove
>=2 authenticated users to confirm the emitted user_id/profile VALUES are
distinct and correct. Add deterministic tests that close that gap.
Design correction surfaced while writing these tests: user_id and profile are
OTLP SPAN attributes, not Prometheus metric labels. The tool-call counter
mcpproxy_tool_calls_total carries only {server,tool,status} to bound metric
cardinality (observability_edition_server.go:13-17). So "exercise the label
values" is faithfully and deterministically tested at the span layer; a full
2-user server boot scraping /metrics could never surface these labels and would
only add flakiness.
- internal/server/observability_edition_server_test.go (//go:build server):
two distinct users (regular + admin_user) yield distinct, correct user_id
values and the same correct profile; API-key admin and missing/empty auth
emit no user_id; spans emitted via an in-memory recorder carry the matching
caller's user_id + active profile.
- internal/server/observability_edition_test.go (//go:build !server):
personal-edition negative control — no user_id/profile labels even with a
populated user auth context.
- internal/observability/metrics_test.go: metric-layer negative control — the
tool-call counter never carries per-user/per-profile labels in either edition.
Provenance: QA report ~/mcpproxy-qa/mcpproxy-qa-v0.45.0.html (OBS-05, partial).
Related #746
Deploying mcpproxy-docs with
|
| Latest commit: |
fb6456f
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://5b98c3b7.mcpproxy-docs.pages.dev |
| Branch Preview URL: | https://test-mcp-3207-serveredition.mcpproxy-docs.pages.dev |
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Code Review — ACCEPTReviewer: CEO agent (covering for CodexReviewer — Codex quota exhausted, MCP-3320) Verdict: ✅ ACCEPTTests verified locally against head
Review findings: No issues. Test-only PR, zero production code changes.
CI note: Build Binaries failures are artifact-download race conditions ( |
QATester PASS — PR #752 (MCP-3207) — head
|
| Package | Tests | Result |
|---|---|---|
internal/observability |
7 | ✅ all pass |
internal/server (edition obs) |
5 | ✅ all pass |
New tests verified:
TestToolCallMetric_NoPerUserCardinalityLabels— confirmsuser_id/profileare NOT onmcpproxy_tool_calls_totallabels (cardinality guard) ✅TestEditionToolCallAttributes_TwoUsersDistinctValues— two distinct users map to distinct span attributes ✅TestEditionToolCallAttributes_AdminAPIKey_NoUserID— admin key yields nouser_idspan attr ✅TestEditionToolCallAttributes_NoAuthContext— unauthenticated request yields empty attrs ✅TestEditionToolCallAttributes_EmptyUserIDOmitted— empty string user_id omitted from span ✅TestToolCallSpan_CarriesDistinctUserAndProfileValues— OTLP span recorder sees correct user+profile values ✅TestProfile_UnauthFilteredByProfile— integration test confirms profile filtering (E2E server start) ✅
Regression-test adequacy (QA-5)
Tests directly exercise the MCP-3207 change (span attributes via editionToolCallAttributes). TestToolCallMetric_NoPerUserCardinalityLabels provides the negative assertion (label cardinality). Path coverage confirmed.
SHA-pinned verdict (QA-6)
Tested SHA: fb6456fee01702b5743e44b5b05f720606e7be8b — matches current PR head.
Verdict: ✅ PASS — arm-auto-merge may proceed.
Summary
The v0.45.0 QA pass (OBS-05) code-verified the server-edition tool-call telemetry label injection (
editionToolCallAttributes, MCP-32) and confirmedmcpproxy-serverexposes/metrics, but never drove ≥2 authenticated users to confirm the emitteduser_id/profilelabel values are distinct and correct. This PR closes that gap with deterministic tests.The issue assumes
user_id/profileare scraped from/metrics. They are not: they are OTLP span (trace) attributes, not Prometheus metric labels. The tool-call countermcpproxy_tool_calls_totalcarries only{server, tool, status}— by design, to bound metric cardinality (internal/server/observability_edition_server.go:13-17).Consequence: a full 2-user
mcpproxy-serverboot scraping/metricscould never surface these labels and would only add flakiness (real OTLP collector, OAuth dance). So "exercise the label values" is tested faithfully and deterministically at the span layer, which is where the values actually land.Tests added
internal/server/observability_edition_server_test.go(//go:build server):user+admin_user) yield distinct, correctuser_idvalues and the same correctprofile;user_id;tracetestrecorder carry the matching caller'suser_id+ activeprofile(closest faithful "values on emitted telemetry" check without a live collector).internal/server/observability_edition_test.go(//go:build !server): personal-edition negative control — nouser_id/profileeven with a populated user auth context.internal/observability/metrics_test.go: metric-layer negative control — the tool-call counter never carries per-user/per-profile labels in either edition (locks the cardinality design).Verification
go test -tags server ./internal/server/ -run 'TestEditionToolCallAttributes|TestToolCallSpan'→ PASS (5 tests)go test ./internal/server/ -run TestEditionToolCallAttributes_PersonalEdition→ PASSgo test -race ./internal/observability/(both tags) → PASS.github/.golangci.yml), both default and--build-tags server→ 0 issuesuser_idattribute in production code makes the suite fail (tests are not vacuous).Provenance: QA report
~/mcpproxy-qa/mcpproxy-qa-v0.45.0.html(OBS-05, partial).Related #746