Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ddtrace/llmobs/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
PROPAGATED_LLMOBS_TRACE_ID_KEY = "_dd.p.llmobs_trace_id"

UNKNOWN_MODEL_PROVIDER = "unknown"
UNKNOWN_MODEL_NAME = "unknown"

INPUT_PROMPT = "_ml_obs.meta.input.prompt"

Expand Down
6 changes: 4 additions & 2 deletions ddtrace/llmobs/_integrations/google_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from ddtrace.llmobs._constants import OUTPUT_TOKENS_METRIC_KEY
from ddtrace.llmobs._constants import REASONING_OUTPUT_TOKENS_METRIC_KEY
from ddtrace.llmobs._constants import TOTAL_TOKENS_METRIC_KEY
from ddtrace.llmobs._constants import UNKNOWN_MODEL_NAME
from ddtrace.llmobs._constants import UNKNOWN_MODEL_PROVIDER
from ddtrace.llmobs._utils import _get_attr
from ddtrace.llmobs._utils import safe_json
from ddtrace.llmobs.types import Message
Expand Down Expand Up @@ -64,15 +66,15 @@ def extract_provider_and_model_name(
model_path = _get_attr(instance, model_name_attr, "")

if not model_path or not isinstance(model_path, str):
return "custom", "custom"
return UNKNOWN_MODEL_PROVIDER, UNKNOWN_MODEL_NAME

model_name = model_path.split("/")[-1] if "/" in model_path else model_path

for prefix in KNOWN_MODEL_PREFIX_TO_PROVIDER.keys():
if model_name.lower().startswith(prefix):
provider_name = KNOWN_MODEL_PREFIX_TO_PROVIDER[prefix]
return provider_name, model_name
return "custom", model_name if model_name else "custom"
return UNKNOWN_MODEL_PROVIDER, model_name if model_name else UNKNOWN_MODEL_NAME


def normalize_contents_google_genai(contents) -> list[dict[str, Any]]:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
fixes:
- |
LLM Observability: Change the default ``model_provider`` and ``model_name`` to ``"unknown"`` from ``"custom"``
when a model did not match any known provider prefix in the Google GenAI, VertexAI, and Google ADK integrations.
8 changes: 4 additions & 4 deletions tests/contrib/google_genai/test_google_genai.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ async def test_google_genai_generate_content_async_stream_error(
("qodo-7b", "qodo", "qodo-7b"),
("mars-7b", "camb.ai", "mars-7b"),
# edge cases
("weird_directory/unknown-model", "custom", "unknown-model"),
("", "custom", "custom"),
("just-a-slash/", "custom", "custom"),
("multiple/slashes/in/path/model-name", "custom", "model-name"),
("weird_directory/unknown-model", "unknown", "unknown-model"),
("", "unknown", "unknown"),
("just-a-slash/", "unknown", "unknown"),
("multiple/slashes/in/path/model-name", "unknown", "model-name"),
],
)
def test_extract_provider_and_model_name(model_name, expected_provider, expected_model):
Expand Down
Loading