Repository navigation
Ingester: forward the running commit to the platform; mark TestClient requests without reclassifying them - #54
Merged
Conversation
…unning commit A FastAPI/Starlette test suite that runs with an exporter and no environment sent its errors as production. A resourceSpans entry with no deployment.environment(.name) now stores a request's trace as `test` when a SERVER span of it carries the exact user agent `testclient` (read before the identifying drop, which adds `autter.test_client: true` and still drops the user agent) or the exact host `testserver`. Per trace, never per process: both are client-controlled headers. An explicit environment is never rewritten. /v1/logs records follow the same rule from their own attributes. Occurrences now carry `commit` (deployment.commit, else vcs.ref.head.revision; event, then span or record, then resource), only when 7-40 hex, lower-cased, and copy it into the attributes as deployment.commit when absent. The sink emits it only when valid. Fixtures recorded from the FastAPI recipe app under TestClient (test-fixtures/python/record_fastapi_testclient.py). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Remove the test-client reclassification. The user agent `testclient`, the host `testserver` and the peer address come from the caller, so on a production app that names no environment a caller could have its own errors stored as `test`, out of default views and paging. The environment is again the resource's deployment.environment(.name), else production, on traces and logs alike; test runs are to set deployment.environment=test from the process (SDK work, separate PRs). `autter.test_client: true` stays on a SERVER span whose raw user agent is exactly `testclient`, added before the user agent is dropped, as a hint nothing in the ingester acts on. Commit forwarding is unchanged. Tests now pin the safe behaviour on the recorded TestClient fixtures: no environment is production, explicit test is test, staging stays staging. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
What users saw
commitfield ("once the ingester forwards it"). The ingester never forwarded the commit, so the map stayed empty for commits reported by SDKs.TestClient, with an exporter configured and no environment set, sends its errors asproduction. This PR does not change that inside the ingester (see below). Those runs will setdeployment.environment=testfrom the process instead, in separate SDK PRs.What changes
Running commit (
types.ts,normalize-otlp.ts,logs.ts,sink.ts)RuntimeOccurrenceInput.commit?: string. It comes fromdeployment.commit, elsevcs.ref.head.revision.deployment.commit, the commit is copied there as well, for the platform's lazy ClickHouse read.sinkOccurrencechecks the value again and emitscommitonly when it is valid. Nothing else from the resource is forwarded (no repository URL)./v1/logserrors carry it too.TestClient marker, a hint only (
identifying.ts)user_agent.original/http.user_agentis exactlytestclientgetsautter.test_client: true. It is added in the identifying filter before the user agent is dropped, and the user agent is still dropped.AUTTER_KEEP_IDENTIFYING_ATTRIBUTES=true, no IP hash), the request passes through the filter untouched, so the raw user agent is stored instead of the marker.The environment never comes from the request. The environment is the resource's
deployment.environment.nameordeployment.environment, elseproduction, exactly as on main. That holds for traces and logs alike.The user agent, the host and the peer address all come from the caller. If the ingester reclassified on them, a caller could get its own errors on a production app stored as
test, out of default views and paging. Host keys are also inconsistent across instrumentations. An earlier revision of this PR reclassified per trace; that is removed. The ingester README says how to separate test traffic: setdeployment.environment=testin the test run.Fixtures (kept for the SDK builders):
test-fixtures/python/fastapi-testclient{,-staging}.otlp.{json,pb}.fastapi.testclient.TestClient.test-fixtures/python/record_fastapi_testclient.py. CI does not run it, because TestClient needs httpx.http.user_agent: testclient,http.host: testserver,http.server_name: testserver.Tests
normalize.test.tsandlogs.test.ts:testorstagingis kept)vcs.ref.head.revisionfallback, the event beats the span and the resource, invalid values dropped, absence emits no fieldidentifying.test.ts, posting the recorded fixture to the server:production, and the server spans carry the marker and no user agentdeployment.environment=testset explicitly, it is stored asteststagingstaysstagingpython-otel.test.ts: the same three outcomes on the fixtures, from both JSON and protobuf.sink.test.tsandserver.sink.test.ts: valid SHA, invalid values dropped, the event value wins, absence emits no field, and environments over the wire.Local:
npm test -w @autter/otlp-ingester(735 pass),tsc --noEmit.Deploys on merge. The commit field is additive, and environment handling is unchanged from main.
🤖 Generated with Claude Code