Repository navigation
Description
Problem Description
The transform/key_data processor in k8s/otel/values.yaml (#4518, PR #4520) does not delete the request bodies of LiteLLM management-endpoint spans. Some of these bodies can hold a raw virtual key or a callback secret. Tempo can thus store key data from the gateway.
The gateway (ghcr.io/berriai/litellm:v1.103.10, callbacks: ["otel"], no LITELLM_OTEL_V2) uses the legacy OpenTelemetry logger. For each management endpoint that has an http_request argument, _emit_management_endpoint_otel_span (litellm/proxy/management_helpers/utils.py) reads the parsed request body. The success hook and the failure hook (litellm/integrations/opentelemetry.py, lines 3390 and 3448) write one span attribute request.<field> for each body field. _CREDENTIAL_FIELDS filters only the response, not the request body.
Affected attributes:
request.keyon/key/blockand/key/unblock(BlockKeyRequest.key). The docstring says that this value can be the unhashed key (sk-...).request.callback_varson/team/{team_id}/callback(dict[str, str]of callback secrets).
The present rules do not match these names: ^metadata[.](user_api_key_|requester_custom_headers) and (?i)(authorization|api[-_]?key) do not match request.key or request.callback_vars. A raw sk- key is not 64-digit hex, so replace_all_patterns does not mask it. The gate check GATEWAY_KEY_ATTRIBUTES (tests/gate/k8s_checks/otel_collector.py) does not list these attributes, so the k8s row does not find the gap.
The path is latent: the review found no request.* span attribute in Tempo since 2026-11-11T00:00Z. The gateway keeps virtual keys in its database (k8s/README.md), so an operator call to /key/block or a team callback set-up writes the data.
Reproduction Steps
- Read
litellm/proxy/management_helpers/utils.py(_emit_management_endpoint_otel_span) andlitellm/integrations/opentelemetry.py(async_management_endpoint_success_hook) of LiteLLM v1.103.10. - Send a
/key/blockrequest with body{"key": "sk-example"}to the gateway. - Find the
/key/blockspan in Tempo. It has the attributerequest.keywith the valuesk-example.
Without the cluster: add "request.key": "sk-example" and "request.callback_vars": '{"langfuse_secret_key": "example"}' to GATEWAY_KEY_ATTRIBUTES and run the k8s row of devops ci. The check fails.
Expected vs Actual Behavior
Expected: the Collector deletes every gateway span attribute that can hold key data before the Tempo exporter.
Actual: request.key and request.callback_vars of management spans go to Tempo unchanged.
Proposed Fix
Use one deny rule by prefix, not one rule for each field. Traces do not need management request or response bodies. Only the management hooks write request.* and response.* attributes in LiteLLM v1.103.10, so the rule removes no model, route, token or error attribute.
- In
transform/key_data, add one span statement:delete_matching_keys(span.attributes, "^(request|response)[.]") where resource.attributes["service.name"] == "llm-gateway". - Add
request.key(rawsk-value),request.callback_varsand oneresponse.*field toGATEWAY_KEY_ATTRIBUTES, so that the k8s row fails if this path comes back. - Extend the requirement "The Collector deletes gateway key data before Tempo" in
openspec/specs/llm-telemetry-content/spec.mdto cover management request and response bodies.
Environment Diagnostics
- Gateway: LiteLLM
v1.103.10, legacy OTel logger. - Collector: OpenTelemetry Collector contrib v0.161.0,
transform/key_datawitherror_mode: propagate.
Logs, Traces, or Terminal Output
Source review of LiteLLM v1.103.10 (litellm/proxy/management_endpoints/key_management_endpoints.py: block_key and unblock_key take http_request; team_callback_endpoints.py: add_team_callbacks takes http_request).
Source: #4520
Proposed design
Problem statement
The transform/key_data processor leaves the request and response bodies of LiteLLM management endpoints on gateway spans: a /key/block call can write a raw sk- key to Tempo as request.key, and a team callback can write callback secrets as request.callback_vars. The k8s gate lists neither attribute, and its statement reader cannot read a pattern that holds a group together with a where clause, so it would reject the prefix rule that fixes the leak. Add one gateway-scoped prefix deny rule, guard it in the gate fixtures and the reader, and record it in the spec, the processor comment and the gateway telemetry docs.
Acceptance criteria
Requirement: Gateway management bodies deleted
The traces pipeline of the Collector SHALL delete every span attribute whose name starts with request. or response. on a span whose service.name is llm-gateway.
Scenario: Gateway management span loses its bodies
- WHEN The
k8srow applies the statements oftransform/key_datato allm-gatewayspan withrequest.keysk-example,request.callback_vars,response.callback_varsand the kept model attributes. - THEN The span keeps no attribute whose name starts with
request.orresponse., and it keepsgen_ai.request.model,http.route,gen_ai.usage.input_tokensanderror.type.
Requirement: Other services keep request attributes
The prefix deny rule SHALL apply only to a span whose service.name is llm-gateway.
Scenario: devops-cli span keeps a request attribute
- WHEN The
k8srow applies the statements to adevops-clispan withrequest.keysk-exampleandreview.digest. - THEN The span keeps
request.keysk-exampleandreview.digest.
Requirement: Gate check reads a grouped pattern
The statement reader of the k8s gate check SHALL read a delete_matching_keys statement whose quoted pattern holds a group and whose where clause names the gateway.
Scenario: Grouped pattern with a where clause
- WHEN The
k8srow readsdelete_matching_keys(span.attributes, "^(request|response)[.]") where resource.attributes["service.name"] == "llm-gateway"fromk8s/otel/values.yaml. - THEN The check applies the pattern
^(request|response)[.]to the gateway span and raises nothe check does not readassertion.
Requirement: Gate fixture covers management bodies
GATEWAY_KEY_ATTRIBUTES in the k8s gate check SHALL include request.key with a raw sk- value, request.callback_vars with a callback secret, and response.callback_vars.
Scenario: Gate fixture holds the management attributes
- WHEN The
k8srow readsGATEWAY_KEY_ATTRIBUTES. - THEN The mapping holds
request.keysk-example,request.callback_varswithlangfuse_secret_key, andresponse.callback_vars.
Requirement: Spec covers management bodies
The llm-telemetry-content spec SHALL state that the Collector deletes the gateway management request.* and response.* span attributes before Tempo.
Scenario: Spec names the management bodies
- WHEN A reader opens the requirement
The Collector deletes gateway key data before Tempo. - THEN The requirement names the
request.*andresponse.*management body attributes, and a scenario checks that a gateway span loses them while a devops-cli span keepsrequest.key.
Requirement: Processor comment names management bodies
The comment of transform/key_data in k8s/otel/values.yaml SHALL name the management request.* and response.* body attributes beside the other key rules.
Scenario: Processor comment names the bodies
- WHEN A reader opens
k8s/otel/values.yamlattransform/key_data. - THEN The comment names the management request and response bodies, the raw key of
/key/blockand the gateway condition.
Requirement: Gateway docs name management bodies
The Gateway spans paragraph of k8s/README.md SHALL state that the Collector deletes the management request.* and response.* span attributes of the gateway.
Scenario: README names the management bodies
- WHEN A reader opens the
Gateway spansparagraph ofk8s/README.md. - THEN The paragraph names the management request and response body attributes beside the existing key attributes and the 64-digit hash rule.
Existing Tool Considered
No alternatives check has run. The OpenTelemetry Collector Contrib transform processor with the OTTL delete_matching_keys function (contrib v0.161.0, k8s/otel/values.yaml:83-94) is open, maintained and already in the traces pipeline. It covers the need and lacks only the ^(request|response)[.] pattern, which this change adds. No new runtime code is built; the project's own gate check only needs its statement reader to read quoted arguments so that it can read the new pattern.
Key questions
- Which OTTL statement removes the management request and response bodies from gateway spans?: Add one span statement to
transform/key_data:delete_matching_keys(span.attributes, "^(request|response)[.]") where resource.attributes["service.name"] == "llm-gateway". The service condition keeps the rule off every other service. (best practice) [sources: k8s/otel/values.yaml:88, k8s/otel/values.yaml:90, tests/gate/k8s_checks/otel_collector.py:31]- Chosen: One prefix deny rule on gateway spans. It removes every current and future
request.*andresponse.*field, and the service condition keeps other spans. - Rejected: One rule for each known field. It misses a new management field and needs an edit for each endpoint.
- Rejected: One prefix deny rule for all services.
request.*andresponse.*are generic HTTP names that another service's instrumentation can write, while only the LiteLLM management hooks write them here. - Rejected: A regex on values.
replace_all_patternsrewrites a value but cannot delete an attribute, and a rawsk-key is not a 64-digit hex value.
- Chosen: One prefix deny rule on gateway spans. It removes every current and future
- Does the prefix deny rule need a statement for span events?: No. Add a span statement only. The management hooks write the request body as span attributes, and an event-context statement cannot remove a span attribute; the
spaneventgroup keeps its refused-key hash rule. (best practice) [sources: k8s/otel/values.yaml:79, k8s/otel/values.yaml:91, openspec/changes/archive/2026-11-11-4518-export-gateway-spans-without-key-metadata/design.md:7]- Chosen: Span statement only. The affected attributes are span attributes, and the processor comment and the archived design record why the two contexts are separate groups.
- Rejected: Span and span event statements. An event statement runs on the exception event, not on the span, so it removes none of the management body attributes and adds a statement with no effect.
- Can the
k8sgate check read the new statement as written?: No._STATEMENTreads the arguments with a greedy.*and backtracks only to the last)before awhereclause, so the)of(request|response)makes the fullmatch fail and the check raisesthe check does not read. Read the arguments as a comma-separated list of double-quoted strings intests/gate/k8s_checks/otel_collector.py. (best practice) [sources: tests/gate/k8s_checks/otel_collector.py:73, tests/gate/k8s_checks/otel_collector.py:105, k8s/otel/values.yaml:90]- Chosen: Read the quoted arguments. It accepts any pattern the rule needs, including a group, and still fails on a function, a context or an argument form the check does not know.
- Rejected: Make the
.*non-greedy. It stops at the first)and only succeeds because thewheregroup forces a longer match; it still reads arbitrary text as an argument. - Rejected: Drop the group from the OTTL pattern.
^request[.]|^response[.]fits the rule to a reader limitation and breaks again on the next grouped pattern. - Rejected: Leave the reader unchanged. The
k8srow raisesthe check does not readon the new statement, so the change cannot pass CI.
- Which gate attributes prove the management body path?: Add
request.keysk-example,request.callback_vars{"langfuse_secret_key": "example"}andresponse.callback_varstoGATEWAY_KEY_ATTRIBUTES. (best practice) [sources: tests/gate/k8s_checks/otel_collector.py:31, tests/gate/k8s_checks/otel_collector.py:173]- Chosen: request.key, request.callback_vars and response.callback_vars. It covers the raw key, the callback secret, and both branches of the prefix rule with one field name on each side.
- Rejected: Only request.key and request.callback_vars. No fixture exercises
response.*, so a rule that misses the second branch still passes. - Rejected: A synthetic response.example. It names a field that a management response does not hold, while the same field on both prefixes proves the alternation covers each side.
- Should the gate test prove that a non-gateway span keeps a
request.*attribute?: Yes. Addrequest.keysk-exampletoOTHER_SERVICE_ATTRIBUTESand keep it in the expected devops-cli span. (best practice) [sources: tests/gate/k8s_checks/otel_collector.py:64, tests/gate/k8s_checks/otel_collector.py:180]- Chosen: Add
request.keyto the devops-cli span. It tests the service condition, not only the deletion; a missing condition would delete the attribute and fail the check. - Rejected: Test only gateway spans. A rule without the service condition would pass, and every service would lose its
request.*attributes.
- Chosen: Add
- How do the spec and the docs record the management body rule?: Extend the requirement
The Collector deletes gateway key data before Tempoinopenspec/specs/llm-telemetry-content/spec.mdto name the gateway managementrequest.*andresponse.*span attributes and add a scenario for them, and name the rule in theGateway spansparagraph ofk8s/README.mdand in the comment oftransform/key_data. (best practice) [sources: openspec/specs/llm-telemetry-content/spec.md:55, k8s/README.md:176, k8s/otel/values.yaml:73]- Chosen: Extend the existing requirement, README paragraph and processor comment. One requirement keeps the Collector key rule in one place, and both prose passages describe the same processor, so they must name the new rule.
- Rejected: Add a separate requirement. It splits one processor rule across two requirements.
- Rejected: Change only the code and the gate. The spec, the README and the processor comment would describe a rule that no longer matches the processor.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 11, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
fixprefix of the title gives the type.(k8s)scope of the title gives the scope.Raw API keys and callback secrets can be stored in Tempo, which is a security gap even though the path is currently latent.It prevents raw virtual keys and callback secrets from reaching Tempo, protecting operator credentials.The fix adds one span delete rule, three gate-check entries, and one spec sentence.Both items deal with gateway span key-data filtering in the transform/key_data processor, but #4518 covers model and route attributes while the candidate adds management-endpoint request and response body deletion.devops-cli-service commentedon Nov 11, 2026
Status set to Ready at 5f75d25 (see proposed design in issue body).
fix(k8s): delete gateway management bodies from spans
devops-cli-service commentedon Nov 11, 2026
Released in v0.112.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.112.0
devops-cli-service commentedon Nov 11, 2026
Live since 2026-11-11 14:13 UTC