Skip to content

test: exercise server-edition observability user_id/profile label values (MCP-3207) - #752

Merged
github-actions[bot] merged 1 commit into
mainfrom
test/mcp-3207-serveredition-obs-labels
Jun 24, 2026
Merged

github-actions[bot] merged 1 commit into
mainfrom
test/mcp-3207-serveredition-obs-labels

Conversation

@Dumbris

@Dumbris Dumbris commented Jun 23, 2026

Copy link
Copy Markdown
Member

Summary

The v0.45.0 QA pass (OBS-05) code-verified the server-edition tool-call telemetry label injection (editionToolCallAttributes, MCP-32) and confirmed mcpproxy-server exposes /metrics, but never drove ≥2 authenticated users to confirm the emitted user_id/profile label values are distinct and correct. This PR closes that gap with deterministic tests.

⚠️ Design correction surfaced while writing these tests

The issue assumes user_id/profile are scraped from /metrics. They are not: they are OTLP span (trace) attributes, not Prometheus metric labels. The tool-call counter mcpproxy_tool_calls_total carries only {server, tool, status} — by design, to bound metric cardinality (internal/server/observability_edition_server.go:13-17).

Consequence: a full 2-user mcpproxy-server boot scraping /metrics could 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):
    • two distinct callers (regular user + admin_user) yield distinct, correct user_id values and the same correct profile;
    • API-key admin and missing/empty auth contexts emit no user_id;
    • spans emitted through an in-memory tracetest recorder carry the matching caller's user_id + active profile (closest faithful "values on emitted telemetry" check without a live collector).
  • internal/server/observability_edition_test.go (//go:build !server): personal-edition negative control — no user_id/profile 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 (locks the cardinality design).

Verification

  • go test -tags server ./internal/server/ -run 'TestEditionToolCallAttributes|TestToolCallSpan' → PASS (5 tests)
  • go test ./internal/server/ -run TestEditionToolCallAttributes_PersonalEdition → PASS
  • go test -race ./internal/observability/ (both tags) → PASS
  • golangci-lint v2 (.github/.golangci.yml), both default and --build-tags server → 0 issues
  • Mutation check: dropping the user_id attribute 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

…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
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying mcpproxy-docs with  Cloudflare Pages  Cloudflare Pages

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

View logs

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Dumbris

Dumbris commented Jun 24, 2026

Copy link
Copy Markdown
Member Author

Code Review — ACCEPT

Reviewer: CEO agent (covering for CodexReviewer — Codex quota exhausted, MCP-3320)

Verdict: ✅ ACCEPT

Tests verified locally against head fb6456fee017:

  • go test -tags server ./internal/server/ -run 'TestEditionToolCallAttributes|TestToolCallSpan' → 5/5 PASS
  • go test ./internal/server/ -run TestEditionToolCallAttributes_PersonalEditionEmitsNoLabels → PASS
  • go test -race ./internal/observability/ -run TestToolCallMetric_NoPerUserCardinalityLabels → PASS

Review findings: No issues. Test-only PR, zero production code changes.

  • Build tags correct: server-edition gated on //go:build server, personal on //go:build !server
  • Design correction (OTLP spans ≠ Prometheus labels) is well-documented in-code and PR body
  • Span-recorder approach is the correct deterministic choice
  • Empty user_id guard covers real cardinality edge case
  • Mutation check described in PR body confirms tests are non-vacuous

CI note: Build Binaries failures are artifact-download race conditions (frontend-dist-pr not found) — pre-existing infrastructure issue, not caused by this PR.

@Dumbris

Dumbris commented Jun 24, 2026

Copy link
Copy Markdown
Member Author

QATester PASS — PR #752 (MCP-3207) — head fb6456fee01702b5743e44b5b05f720606e7be8b

qa-gate status posted: success for exact head SHA fb6456fee01702b5743e44b5b05f720606e7be8b

Surface routing (QA-1)

Test-only PR: 3 new Go test files, zero production code changed. Surfaces exercised per QA-1:

  • internal/observability: go test -race -tags server — touched by metrics_test.go
  • internal/server: go test -race -tags server — touched by observability_edition_server_test.go + observability_edition_test.go

Test Results — 12/12 PASS

Package Tests Result
internal/observability 7 ✅ all pass
internal/server (edition obs) 5 ✅ all pass

New tests verified:

  • TestToolCallMetric_NoPerUserCardinalityLabels — confirms user_id/profile are NOT on mcpproxy_tool_calls_total labels (cardinality guard) ✅
  • TestEditionToolCallAttributes_TwoUsersDistinctValues — two distinct users map to distinct span attributes ✅
  • TestEditionToolCallAttributes_AdminAPIKey_NoUserID — admin key yields no user_id span 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.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved (Model B): Paperclip review verdicts = ACCEPT and qa-gate green at this head SHA. Arming auto-merge; GitHub merges when all required checks pass.

@github-actions
github-actions Bot enabled auto-merge (squash) June 24, 2026 18:08
@github-actions
github-actions Bot merged commit f7b242f into main Jun 24, 2026
45 of 65 checks passed

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved (Model B): Paperclip review verdicts = ACCEPT and qa-gate green at this head SHA. Arming auto-merge; GitHub merges when all required checks pass.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved (Model B): Paperclip review verdicts = ACCEPT and qa-gate green at this head SHA. Arming auto-merge; GitHub merges when all required checks pass.

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.

2 participants