refactor(otel v2): move the internal-spans sentinel and env var name to constants.py

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
mrinal 2026-09-22 23:19:25 +00:00
parent 4a92e3055f
commit 35937f57e7
2 changed files with 7 additions and 5 deletions

View file

@ -1677,6 +1677,11 @@ LITELLM_LOGGING_NO_UPSTREAM_LLM_CALL: Final = "litellm_no_upstream_llm_call"
# the key's values after the team metadata merge so a key outranks its team).
OTEL_SERVICE_NAME_METADATA_KEYS: Final = ("otel_service_name_override", "otel_service_name")
# ``litellm_settings: otel_tenant_internal_spans`` value (and its env equivalent) that
# keeps the proxy's own SERVICE and DB_CALL spans out of tenant OTel destinations.
OTEL_EXCLUDE_INTERNAL_SPANS: Final = "exclude"
OTEL_TENANT_INTERNAL_SPANS_ENV: Final = "LITELLM_OTEL_TENANT_INTERNAL_SPANS"
# Key Rotation Constants
LITELLM_KEY_ROTATION_ENABLED: Final = os.getenv("LITELLM_KEY_ROTATION_ENABLED", "false")
LITELLM_KEY_ROTATION_CHECK_INTERVAL_SECONDS: Final = int(

View file

@ -20,6 +20,7 @@ from opentelemetry.trace.propagation.tracecontext import (
TraceContextTextMapPropagator,
)
from litellm.constants import OTEL_EXCLUDE_INTERNAL_SPANS, OTEL_TENANT_INTERNAL_SPANS_ENV
from litellm.integrations.otel.model.semconv import HTTP
from litellm.types.utils import OtelInternalSpans
@ -401,10 +402,6 @@ def tenant_destinations_are_additive() -> bool:
return isinstance(configured, str) and configured.strip().lower() == ADDITIVE_DESTINATION_MODE
EXCLUDE_INTERNAL_SPANS: Final = "exclude"
OTEL_TENANT_INTERNAL_SPANS_ENV: Final = "LITELLM_OTEL_TENANT_INTERNAL_SPANS"
def tenant_internal_spans_default() -> OtelInternalSpans:
"""The ``internal_spans`` a tenant destination gets when its own callback vars name none.
@ -414,7 +411,7 @@ def tenant_internal_spans_default() -> OtelInternalSpans:
import litellm
configured: Final = litellm.otel_tenant_internal_spans or os.environ.get(OTEL_TENANT_INTERNAL_SPANS_ENV)
if isinstance(configured, str) and configured.strip().lower() == EXCLUDE_INTERNAL_SPANS:
if isinstance(configured, str) and configured.strip().lower() == OTEL_EXCLUDE_INTERNAL_SPANS:
return "exclude"
return "include"