Skip to content

feat(k8s): export gateway spans without key metadata #4518

Closed

Description

@dan-petty

Problem or Motivation

The LiteLLM gateway (namespace llm, image ghcr.io/berriai/litellm:v1.103.10) sends no spans. Its config has callbacks: ["prometheus"] only (k8s/llm/gateway/config.yaml), and the Deployment sets no OTEL_* variable. Tempo has no gateway service. Thus the time that a call waits in the gateway queue, and the time of its retries and fallbacks, is not visible in a trace.

The LiteLLM OpenTelemetry callback writes key data on each span, also when message logging is off. The LiteLLM page says: "LiteLLM emits metadata.user_api_key_* attributes (key hash, key alias, org ID, user ID, team ID)" and "LiteLLM iterates standard_logging_payload["metadata"] and emits each entry as metadata.{key}" (https://docs.litellm.ai/docs/observability/opentelemetry_integration). At v1.103.10, set_attributes in litellm/integrations/opentelemetry.py writes each metadata key, and StandardLoggingUserAPIKeyMetadata in litellm/types/utils.py holds user_api_key_hash, user_api_key_alias, user_api_key_user_email and user_api_key_auth_metadata. A refused key also puts its SHA-256 hash in the error text: "Key Hash (Token) =" (litellm/proxy/auth/user_api_key_auth.py), which goes to the exception attribute and to the exception event.

Proposed Solution & Architectural Design

Defence in depth, as the owner decided on 2026-11-11:

  1. Gateway: add the otel callback and keep prometheus. Set turn_off_message_logging: true; the LiteLLM page says that this setting "forces NO_CONTENT" and overrides each other content setting. Send OTLP over HTTP to the in-cluster Service of the Collector on port 4318. Keep LiteLLM metrics and events export off (the defaults).
  2. Collector (k8s/otel/values.yaml): add a transform processor to the traces pipeline, before the Tempo exporter. It deletes each metadata.user_api_key_* and metadata.requester_custom_headers attribute, and each attribute whose name holds authorization or api-key, from spans and span events. It replaces each 64-character hex value (a SHA-256 key hash) in gateway spans and events. Docs: the transform processor and the OTTL functions delete_matching_keys and replace_all_patterns at v0.161.0 of opentelemetry-collector-contrib.
  3. Network: let the gateway pod send to namespace otel on TCP 4318. The Collector policy already admits port 4318 from all namespaces.

A check of the k8s row of devops ci proves that the processor is in the traces pipeline before the exporter, and that its patterns delete the LiteLLM key attributes and keep the other attributes.

Gateway spans become children of devops-cli spans only when the client sends traceparent. UnifiedClient sends it now. The pydantic-ai path sends it after the agent spans change of #2536. This item ships alone.

Target Subsystem

Kubernetes & Minikube Automation

Existing Tool Considered

The LiteLLM otel callback (built in) and the OpenTelemetry Collector transform processor (in the contrib image that runs now). No code is built.

Activity

  1. added
    source/agent
    type/feature
    scope/k8s
    status/new
    value/medium
    effort/medium
    on Nov 11, 2026
  2. dan-petty commented on Nov 11, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/feature. The feat prefix of the title gives the type.
    • Scope: scope/k8s. The (k8s) scope of the title gives the scope.
    • Priority: P2-Medium. It improves observability of gateway queue time and retries but does not block a release or fix a defect.
    • Value: Medium. Users gain visibility into gateway wait time, retries, and fallbacks in traces.
    • Effort: Medium. It needs gateway config, a Collector transform processor, and a network policy change across three components.
    • Related: feat(telemetry): send pydantic-ai spans through the exporter seam #4515, which asks for a different change. Both items send spans through the OTel pipeline, but the candidate adds gateway spans while #4515 adds pydantic-ai spans.
  3. added
    priority/p2-medium
    owner/agent
    status/in-progress
    and removed
    status/new
    on Nov 11, 2026
  4. removed
    status/in-progress
    owner/agent
    on Nov 11, 2026
  5. devops-cli-service commented on Nov 11, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-11 14:13 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/k8ssource/agenttype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions