Skip to content

Desktop Rust backend: add UID logging on successful Gemini proxy requests #7624

Closed

Description

@beastoin

Problem

Successful Gemini proxy requests through the desktop Rust backend do NOT log the user UID. Only rate-limited (429), model-degraded, and BYOK-usage paths log uid=. This blocks per-user cost attribution for Vertex AI spend.

Impact: cannot attribute $16K/mo Vertex AI cost to specific users from logs alone. 50 unique users made 567K successful requests in May — all unattributable.

Code location

  • desktop/Backend-Rust/src/routes/proxy.rs — gemini_proxy and gemini_stream_proxy handlers
  • Lines 125-291 (non-streaming), 319-472 (streaming): no tracing call on the success path between rate limit check and upstream response forwarding

Existing logging pattern (for reference)

// Already logged on rejection/degradation:
tracing::warn!("gemini_proxy: rate limit rejected uid={}", user.uid);        // line 125
tracing::info!("gemini_proxy: degraded uid={} {} -> {}", user.uid, ...);     // line 132
tracing::info!("gemini_proxy: using BYOK Gemini key for uid={}", user.uid);  // line 152

Proposed fix

Add one tracing::info! after the successful upstream response, in both gemini_proxy and gemini_stream_proxy:

tracing::info!("gemini_proxy: forwarded uid={} path={}", user.uid, path);

~3-line change. Same pattern already used for BYOK/degradation log lines.

Context

Filed from desktop-backend code audit for Vertex AI cost attribution report. @beastoin cc @kodjima33

by AI for @beastoin

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions