review: follow-ups to #48 (env default, contextvars unbind, schema tests)#49
Merged
Conversation
…chema tests)
- configmap: default RIPTIDE_ENV to "unknown" instead of "prod" so a
missing overlay patch is loud in Splunk rather than silently tagged
as production.
- deployment: drop stale "index annotation can be overridden" comment
that referenced an annotation we never set.
- access_log middleware: rstrip path before checking _SILENT_PATHS so
/health/ doesn't sneak through; replace clear_contextvars() with
unbind_contextvars(*bound) so we only unbind what we bound (preserves
contextvars set by any outer layer); add a sentinel comment on the
500 fallback.
- noergler/pipeline routers: align log field names with the
cross-source convention — `event_type` (not noergler_event_type),
`status` (not run_status). webhook_source already disambiguates in
Splunk panels.
- AGENTS.md: document the naming convention so the next add-a-source
PR doesn't reinvent it.
- tests/test_log_schema.py: add a regression suite the unification was
supposed to make possible. Two layers:
* call-site: parse the JSON the handler actually wrote (via a stream
swap on the root StreamHandler — capfd/capsys don't reach handlers
that captured sys.stdout before the test started) and assert
required keys, outcome semantics, no Splunk-reserved leaks,
accepted -> deduped on replay, delivery_id even on ignored paths,
request_id propagation, /health silence.
* processor-chain: run the prod processor list on a synthetic event
dict and assert event->msg, level->log_level, reserved stripping,
and service/version/env stamping.
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.
Summary
Addresses the code-review feedback on the merged PR #48 (Splunk-friendly JSON logs):
RIPTIDE_ENVdefault inopenshift/collector/configmap-app.yamlflipped from"prod"to"unknown". A forgotten overlay patch now stands out in Splunk instead of silently mis-tagging records as production.openshift/collector/deployment.yamlabout overridable index annotation dropped — we never set that annotation.access_logmiddleware (src/riptide_collector/main.py):_SILENT_PATHScheck usesrstrip("/")so/health/(trailing slash) is also silenced.clear_contextvars()replaced withunbind_contextvars(*bound)— we only unbind what we bound, preserving any contextvars set by an outer layer.status_code = 500fallback so a future reader doesn't misread it as a bug.noergler_event_type→event_typeinrouters/noergler.py.run_status→statusinrouters/pipeline.py.webhook_sourcealready disambiguates these in Splunk panels; source-namespaced field names are no longer used.tests/test_log_schema.py(new): the schema-regression suite the unification was supposed to enable. Two layers:StreamHandler's stream to an in-memory buffer (capfd/capsys don't reach handlers that capturedsys.stdoutbefore the test started), parse the JSON lines, assert required keys, outcome semantics, no Splunk-reserved leaks, accepted→deduped on replay,delivery_ideven on ignored paths,request_idpropagation,/healthsilence.event→msg,level→log_level, reserved-name stripping, andservice/version/envstamping.Test plan
uv run ruff check . && uv run ruff format --check .uv run pyright— 0 errorsuv run pytest— 179 passed (170 baseline + 9 new schema tests)RIPTIDE_ENVoverlay patch is in place (otherwise records will tagenv=unknown)