From 6163efe0c348d34e910506ae0400908fef37049b Mon Sep 17 00:00:00 2001 From: Arnold Galovics Date: Fri, 9 Oct 2026 19:34:17 +0200 Subject: [PATCH] fix(tags): declare the spend counter key family around the Redis write --- .../proxy/management_endpoints/tag_management_endpoints.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/litellm/proxy/management_endpoints/tag_management_endpoints.py b/litellm/proxy/management_endpoints/tag_management_endpoints.py index 4f8a008031d..2c9ce1ee4fe 100644 --- a/litellm/proxy/management_endpoints/tag_management_endpoints.py +++ b/litellm/proxy/management_endpoints/tag_management_endpoints.py @@ -19,6 +19,7 @@ from typing import TYPE_CHECKING, Final, Protocol, TypedDict, overload from fastapi import APIRouter, Depends, HTTPException, Query from pydantic import TypeAdapter +from litellm._internal_context import service_target from litellm._logging import verbose_proxy_logger from litellm.proxy._types import UserAPIKeyAuth, user_api_key_has_admin_view from litellm.proxy.auth.user_api_key_auth import user_api_key_auth @@ -31,6 +32,7 @@ from litellm.proxy.management_endpoints.common_daily_activity import ( get_daily_activity, ) from litellm.proxy.management_helpers.utils import handle_budget_for_entity +from litellm.proxy.spend_tracking.spend_counter_batch import SPEND_COUNTERS_TARGET from litellm.repositories.daily_activity_buckets import api_key_from_bucket from litellm.repositories.model_repository import ModelRepository from litellm.repositories.table_repositories import ( @@ -490,7 +492,8 @@ async def update_tag( spend_counter_cache.in_memory_cache.set_cache(key=counter_key, value=tag.spend, ttl=60) if spend_counter_cache.redis_cache is not None: try: - await spend_counter_cache.redis_cache.async_set_cache(key=counter_key, value=tag.spend, ttl=60) + with service_target(SPEND_COUNTERS_TARGET): + await spend_counter_cache.redis_cache.async_set_cache(key=counter_key, value=tag.spend, ttl=60) except Exception as redis_err: # noqa: BLE001 # best-effort refresh: a Redis failure must not fail the request # tag.name is admin-supplied; strip CR/LF before it reaches the logs so it # cannot forge additional log lines.