Repository navigation
feat(observability): structured JSON logs for the sandbox manager and log sanitization (#487) - #490
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Member
|
@jaoppb your PR is completely broken. |
Collaborator
Author
will fix it, waiting for the tokens limit to reset |
This was referenced Nov 21, 2026
… log sanitization (#487) - One shared formatter, request context and request middleware (sandbox_manager/structured_logging.py) used by the API and the sandbox manager: service, env, request_id, and trace_id/span_id only when set. - The sandbox manager reads JSON_LOGS, LOG_LEVEL, SERVICE_NAME (autograder-sandbox-manager) and APP_ENV and starts as a Uvicorn factory, so every line, from the first, is structured. - Request lines log the route template, never the raw path, query string or client address; Uvicorn's access line is off and the URL-bearing lines of urllib3/httpx are capped at WARNING (sandbox handles are capabilities, user ids identify students). - X-Request-ID is accepted only when well-formed, echoed, and forwarded by RemoteSandboxClient; the durable worker uses the attempt id. - The AI provider no longer logs prompts (student code) or provider messages.
- Request-dumping libraries (urllib3, httpx, httpcore, openai, botocore, boto3, s3transfer) log warnings only, even at LOG_LEVEL=DEBUG. - Sandbox transport errors and AI provider failures no longer chain the library exception whose message held the handle URL or the request; the Docker host drops its AI client on PROVIDER_UNAVAILABLE instead of inspecting the cause. - Request lines use the "http.request" logger in both services. - Tests: failed-request line, transport traceback, AI provider logs, environment settings, the image's factory command.
ArthurCRodrigues
force-pushed
the
feat/487
branch
from
November 21, 2026 22:58
8fc5774 to
7368f02
Compare
ArthurCRodrigues
approved these changes
Nov 21, 2026
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 #487
Part of webtech-network/prisma-infrastructure#92
Summary
sandbox_manager/structured_logging.py;web/config/logging.pyimports it. Every line carriesservice,envandrequest_id.trace_id/span_idappear only when set; AG-3 ([Observability][AG-3] Instrumentautograder-api&autograder-sandbox-managerwith OpenTelemetry + Cut Release #489) will set them.JSON_LOGS,LOG_LEVEL,SERVICE_NAME(defaultautograder-sandbox-manager) andAPP_ENV. It starts as a Uvicorn factory (--factory sandbox_manager.api:create_app), so importing the module configures nothing and Uvicorn's first lines are already JSON. The module-levelsandbox_manager.api:appis gone; prisma-infrastructure uses the image CMD.http_request_completed/http_request_failedline (loggerhttp.request) per request. The line hasmethod, the route template aspath(<unmatched>when no route matched),statusandduration_ms. Uvicorn's access line is off.X-Request-IDis kept only when it matches[A-Za-z0-9._:-]{1,128}; otherwise it is replaced. The response echoes it, andRemoteSandboxClientforwards it. The durable worker uses the grading attempt id as the request id.Log audit: what no longer reaches a log
/sandboxes/{id}/...paths in Uvicorn access lines, through urllib3/httpx URL logs, and through the chained requests exception in tracebacks (the client now raisesfrom None).external_user_idin/submissions/user/{id}, client IP:port and query strings.openaiSDK. AI provider error messages are gone too: the provider raisesfrom None, and the Docker host now drops its client onPROVIDER_UNAVAILABLEinstead of checking the error's cause.LOG_LEVEL=DEBUG.There is no generic regex scrubber: each leak is fixed where it originates, and Alloy redaction (ADR-001 D7) is the defense in depth.
Out of scope
autograder-api&autograder-sandbox-managerwith OpenTelemetry + Cut Release #489)./metricsbelongs to AG-2 ([Observability][AG-2] Expose Prometheus/metricsfor Autograder API & Grading Pipeline #488).JSON_LOGS=truefor the sandbox manager in deploy lands with INF-5 and the image tag bump.Verification
make testandmake test-webpass locally (1689 + 499 tests).tests/unit/sandbox/test_structured_logging.py,tests/web/test_request_logging.py, and a test for the AI provider's logs.~/.awslogin-provider failure intest_fixture_provider. It passes with the AWS config isolated.🤖 Generated with Claude Code