Repository navigation
feat: structured JSON logs with request ids; readiness that checks dependencies - #81
Merged
Merged
Conversation
…pendencies - api, mcp: structlog JSON on stdout (uvicorn's lines included). A RequestIdMiddleware keeps a well-formed incoming X-Request-ID or makes one, binds it to every log line, echoes it on the response and writes one access line (method, path, status, duration, user on the API). - mcp forwards the id to apps-api and logs each tool call with it; the UI's nginx forwards it on /api and /mcp, generating one if absent. - api: /api/v1/readyz checks the Kubernetes API (namespace list) and, with auth on, the realm JWKS, 3s each; the chart's readiness probe uses it. Failing checks are named, reasons only logged. - mcp: HTTP /healthz, used by both probes instead of tcpSocket. Closes #46 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016pvMUQJoLkBDk6B94TTm45
|
📄 Docs preview for |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016pvMUQJoLkBDk6B94TTm45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #46
What changes
logs.pysets up structlog, with stdlib integration so uvicorn's own lines are JSON too: one object per line withtimestamp,level,logger,eventand fields. The level comes fromLOG_LEVEL.RequestIdMiddleware(pure ASGI):X-Request-IDif it is well formed (≤128 chars ofA-Za-z0-9._:-), otherwise it makes one.duration_ms, and on the API the authenticateduser. Probe paths log at DEBUG./apiand/mcp, or generates one when none arrives.ToolLogMiddlewarere-binds the id from the HTTP request, logstool callwithtool, outcome and duration, andApiClientsends the id to apps-api.GET /api/v1/readyz:list namespaces(limit=1, 3s timeout, already in the API's cluster role) and, with auth on, that the realm JWKS loads (3s; a success is reused for 60s so probes don't hammer Keycloak).timeoutSeconds: 8). Liveness stays on the static/healthz, so an outage takes pods out of rotation without restarting them.GET /healthzreplaces thetcpSocketprobes./readyzin the API reference, plus a "Logs and probes" section andLOG_LEVELin configuration.Not done here: the operator's
readyzis stillhealthz.Ping. The issue mentions it, but its acceptance criteria don't require it.Upgrade notes
Testing
/healthzover HTTP with the id echoed;ApiClientforwards the id or sends none.nginx -tpasses on the rendered config.authz-alice).tool callwith the same id as its/mcpaccess line.ApiClientrun inside the MCP pod sentexec-trace-1, and the API logged it./api/v1/readyzreturned 200 withkubernetesandjwksok. WithOIDC_JWKS_URLpointed at an unresolvable host it returned 503{"jwks":"failed"}and logged the DNS error. After the override was removed it went back to 200.helm template. The cluster runs its vendored chart, so the new probes weren't exercised by kubelet.🤖 Generated with Claude Code
https://claude.ai/code/session_016pvMUQJoLkBDk6B94TTm45