Skip to content

fix(k8s): delete gateway management bodies from spans - #4551

Merged
dan-petty merged 2 commits into
mainfrom
fix/4539-delete-gateway-management-bodies
Nov 11, 2026
Merged

dan-petty merged 2 commits into
mainfrom
fix/4539-delete-gateway-management-bodies

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

The LiteLLM management hooks (v1.103.10) write each field of a management request body as a request.<field> span attribute, and of its response as response.<field>. request.key of /key/block can hold a raw sk- key. request.callback_vars of /team/{team_id}/callback holds callback secrets. The Collector rule transform/key_data did not delete them, so Tempo could store key data.

One span statement now deletes each request.* and response.* attribute of llm-gateway spans. Only the management hooks write these prefixes, so the rule removes no model, route, token or error attribute. The k8s row checks request.key, request.callback_vars and response.data. Only the Collector changes, so no rollout order is necessary.

Closes #4539

Change: openspec/changes/archive/2026-11-11-4539-delete-gateway-management-bodies-from-spans/

@dan-petty dan-petty added type/bug Type bug: the code does not do what it must scope/k8s Kubernetes commands, Helm charts, pods, services, and policies labels Nov 11, 2026
@dan-petty

dan-petty commented Nov 11, 2026 •

Copy link
Copy Markdown
Owner Author

Checks and evidence (2026-11-11).

Fail-to-pass. uv run devops ci fail-to-pass --base origin/main gives: 0 failed on base (0 failed and 0 passed in no changed test files; 0 errored). The fix changes no tests/**/test_*.py file. This is expected. The defect is in a manifest, and the check is a k8s gate check (tests/gate/k8s_checks/otel_collector.py), not a test_*.py file. The Fail-to-Pass Check workflow runs only for src/** changes, and this PR changes no file under src/. The command does not replay gate checks (#4554). The k8s row is the fail-to-pass proof:

  • Base config with the new key attributes: uv run devops ci --only k8s gives k8s: 107 cases, 1 failed (otel_collector.check_the_trace_pipeline_deletes_gateway_key_data_before_tempo, AssertionError).
  • With the new statement: k8s: 107 cases, 0 failed.
  • The check run directly against this values.yaml passes, and against a copy without the new statement it fails.

LiteLLM source v1.103.10 (uv cache): a search of the package for each attribute key that starts with request. or response. (string literals, f-strings, prefix arguments) finds only litellm/integrations/opentelemetry.py lines 3390, 3399 and 3448, the management success and failure hooks. Tempo span attribute names (scope span, 2026-11-11) hold no request.* or response.* name.

Collector config. otelcol-contrib validate of image otel/opentelemetry-collector-contrib:0.161.0 (the live version) accepts the rendered config of k8s/otel/values.yaml (null receivers removed, as the chart does). A copy with delete_matching_keyz in the new statement fails with undefined function "delete_matching_keyz", so validate parses the statement.

Throwaway Collector. The same image, with transform/key_data from this branch and a debug exporter, got a /key/block span of llm-gateway and a devops-cli span over OTLP/JSON. The gateway span kept http.route, gen_ai.request.model, gen_ai.usage.input_tokens and error.type, and lost request.key, request.callback_vars and response.data. The devops-cli span kept its request.id. The same Collector without the new statement exported request.key: Str(sk-example), request.callback_vars and response.data.

Live checks after the merge. Only the Collector changes, so no rollout order is necessary: Argo CD syncs the otel-collector Application and the Collector pod restarts on its new config. Then:

  1. kubectl -n otel rollout status deployment/otel-collector-opentelemetry-collector completes, and the Collector log has no transform/key_data error.
  2. In Grafana Explore on Tempo, this TraceQL query returns no traces for the time after the restart:
    { resource.service.name = "llm-gateway" && span.request.key != nil }
  3. The same query with span.request.callback_vars != nil returns no traces.
  4. The Tempo span attribute names (scope span) hold no new request.* or response.* name from llm-gateway.

The LiteLLM management hooks write each field of a management request
body as a request.* span attribute and of its response as response.*.
On /key/block and /key/unblock, request.key can hold a raw virtual key.
On /team/{team_id}/callback, request.callback_vars holds callback
secrets. The Collector rule transform/key_data did not delete these
attributes, so Tempo could store key data.

One span statement now deletes each request.* and response.* attribute
of llm-gateway spans. In LiteLLM v1.103.10 only the management hooks
write these prefixes. The k8s row checks the three attributes.

Closes #4539
@dan-petty
dan-petty force-pushed the fix/4539-delete-gateway-management-bodies branch from 66466ef to 4896297 Compare November 11, 2026 08:52
@dan-petty

Copy link
Copy Markdown
Owner Author

Review finding (minor), fixed in this PR: the k8s check did not hold the service condition of the new statement. #4539 asks that other services keep their request.* attributes.

  • OTHER_SERVICE_ATTRIBUTES in tests/gate/k8s_checks/otel_collector.py now holds "request.id": "example". The check already compares the devops-cli span with this map, so it now fails if a change removes where resource.attributes["service.name"] == "llm-gateway" from the new statement.
  • Proof with a scratch copy of k8s/otel/values.yaml that has no where clause on the new statement: the old check gave PASS, and the new check gives FAIL. Both checks give PASS on the file of this PR.
  • I put the change into the fix commit (--fixup and --autosquash), so the OpenSpec archive stays the last commit. devops ci --only k8s passes.

@dan-petty
dan-petty merged commit b835d3c into main Nov 11, 2026
53 of 54 checks passed
@dan-petty
dan-petty deleted the fix/4539-delete-gateway-management-bodies branch November 11, 2026 11:59
dan-petty pushed a commit that referenced this pull request Nov 11, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.112.0](v0.111.0...v0.112.0)
(2026-11-11)


### Features

* **k8s:** export gateway spans without key metadata
([#4520](#4520))
([7234d71](7234d71))
* **k8s:** set the homelab domain in container env values
([#4608](#4608))
([a3bcf7c](a3bcf7c))
* **telemetry:** send pydantic-ai spans through the exporter seam
([#4538](#4538))
([fcf2a7a](fcf2a7a))


### Bug Fixes

* **ai:** price cached prompt tokens of chat calls
([#4584](#4584))
([f84bbe6](f84bbe6))
* **devcontainer:** stop uv noise lines in agent shells
([#4592](#4592))
([9ba375c](9ba375c))
* **k8s:** delete gateway management bodies from spans
([#4551](#4551))
([b835d3c](b835d3c))
* **k8s:** set the kube context and namespace on devops pods
([#4514](#4514))
([9087b39](9087b39))
* **roadmap:** a refused spec after the archive is a plan defect
([#4549](#4549))
([1db29f7](1db29f7))
* **roadmap:** count and log the reason of a left-out stage item
([#4541](#4541))
([5600179](5600179))
* **roadmap:** default the step ceiling to twice the budget
([#4556](#4556))
([1dfb6c8](1dfb6c8))
* **roadmap:** explain --trace shows the argument digest
([#4526](#4526))
([c92195f](c92195f))
* **roadmap:** explain totals count dropped model events
([#4543](#4543))
([fe0e979](fe0e979))
* **roadmap:** give each eval verify run its own report file
([#4534](#4534))
([ad27f2d](ad27f2d))
* **roadmap:** one event loop and a time limit for decide_all
([#4585](#4585))
([ec51e01](ec51e01))
* **roadmap:** scoped updates send requests with no row scope
([#4531](#4531))
([5f75d25](5f75d25))
* **roadmap:** the caller gate reads an added parameter span
([#4548](#4548))
([1ba07c1](1ba07c1))
* **roadmap:** the implement shell waits for its command
([#4536](#4536))
([571e044](571e044))
* **roadmap:** the module-test and caller gates read imports and calls
([#4490](#4490))
([8a22e82](8a22e82))
* **service:** put trace ids on Service JSON log lines
([#4511](#4511))
([0d7a0d2](0d7a0d2))


### Performance Improvements

* **ai:** keep intake embeddings between CLI runs
([#4546](#4546))
([812871e](812871e))
* **roadmap:** intake reads only the issues that changed
([#4552](#4552))
([7dfd155](7dfd155))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/k8s Kubernetes commands, Helm charts, pods, services, and policies type/bug Type bug: the code does not do what it must

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(k8s): delete gateway management bodies from spans

1 participant